Currently working my way through this beginners book and have completed one of the practice projects \'Comma Code\' which asks the user to construct a program which:
I tried this, hope this is what you are looking for :-
spam= ['apples', 'bananas', 'tofu', 'cats']
def list_thing(list):
#creating a string then splitting it as list with two items, second being last word
new_string=', '.join(list).rsplit(',', 1)
#Using the same method used above to recreate string by replacing the separator.
new_string=' and'.join(new_string)
return new_string
print(list_thing(spam))