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:
def sample(values): if len(values) == 0: print("Enter some value") elif len(values) == 1: return values[0] else: return ', '.join(values[:-1] + ['and ' + values[-1]]) spam = ['apples', 'bananas', 'tofu', 'cats'] print(sample(spam))