def sri(z): ... for i in range(len(z)): ... if i<len(z)-1: ... y=z[i]+',' ... else: ... y='and ' + z[-1] ... print(y,end=" ") ... >>> d=['apple','banana','tofu','cat'] >>> p=sri(d)I was unable to get the apostrophe on the final output. I've tried by calling str function for the final output.
[split] Automate the boring stuff, inserting commas in list
Users browsing this thread: 2 Guest(s)