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:
The format statement is cleaner.
This worked for me as well:
def sentence(x): if len(x) == 1: return x[0] return (', '.join(x[:-1])+ ' and ' + x[-1])