Jul-02-2019, 01:31 PM
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.