Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am given these instructions and need to create a function, using for loops and

ID: 3631664 • Letter: I

Question

I am given these instructions and need to create a function, using for loops and while loops, to make the program work correctly. I am using python, so the code needs to work for python.
'''
newjoin(L,glue) takes a list of strings and returns
glue.join(L) -- but using a for loop to build the result
instead of using the built-in string method. In other
words, how would you write the equivalent of the join method
if it was not built in?

>>> L = "one two three four".split()
>>> newjoin(L,"/")
'one/two/three/four'
>>> L = ["","with","car","","gone"]
>>> newjoin(L,"--")
'--with--car----gone'
>>> L = "a b c".split()
>>> S = newjoin(L,'')
>>> S == "abc"
True
'''

Explanation / Answer

Python module for newJoin(L,char) where L is list of element and char variable which takes any characters literal def newJoin(L,char): txt = ' ' for item in L: txt +=str(item)+char print "'", txt ,"'" >>> newJoin(L,"/") ' one/two/three/four/ ' >>> L=["","with","car","","gone"] >>> newJoin(L,"--") ' --with--car----gone-- ' >>> L="a b c".split() >>> S==newJoin(L,'') ' abc ' True >>>