Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- spam = ['apples','bananas', 'tofu','cats']
- newString = None
- def listToString(list):
- list.insert(-1,'and')
- newString = str(list)
- newString = newString[1:-1]
- for i in range(0,len(newString)):
- newString = newString.replace("'",'')
- n = newString.rfind(",") #finds the highest index that contains a comma
- newString = newString[:n] + newString[n+1:] #concactenate to remove comma
- print(newString)
- listToString(spam)
Advertisement
Add Comment
Please, Sign In to add comment