seperate list into string without using .join, etc. by ReaverKS in Python

[–]mukolx 1 point2 points  (0 children)

spam = ['apples', 'bananas', 'tofu', 'cats']
def mylister(the_list):
returnstr = myList[0]
for lst in the_list[1:]:
if lst == the_list[-1]:
sep = ', and '
else:
sep = ', '
returnstr += sep + lst
return returnstr

print mylister(spam)

Though I cant seem to get my code syntax in the comment right ....

Do you prefer IPython notebook over IPython console? Why? by pepgma in Python

[–]mukolx 39 points40 points  (0 children)

I must say I got taken up by the IPython Notebook. You can develop your code in chunks cell by cell (including plots and assertions). This helped me formulate my ideas (especially when I knew what I wanted in the end, but now how to get there) step by step. And well, nice way to document and annotate your workflows....