What does the “x for x in” syntax mean?

This is just standard Python list comprehension. It’s a different way of writing a longer for loop. You’re looping over all the characters in your string and putting them in the list if the character is a digit.

See this for more info on list comprehension.

Leave a Comment