In general on Stack Overflow, you would have been better editing your original question with an update on your progress.
string.punctuation
is definitely a step in the right direction. You've got a few options including:
As to where? If you do it after you create the list, you'll need to apply it to each element individually. But if you split up the your string transformation function calls (split
, join
) on the return line into their own lines, you could do it earlier. Try performing one action at a time, then printing the result to see if you can spot where else you can remove punctuation without having to iterate.