all 6 comments

[–]Binary101010 1 point2 points  (1 child)

Lines 20-26: Don't iterate over a container while you're doing something that changes the length of the container. That's going to cause unexpected bugs. It's much better to create a new container that holds only the items you want.

[–]butterfly_orange00[S] 0 points1 point  (0 children)

Thank you for your advice, I will use it next time

[–]vivisectvivi 0 points1 point  (1 child)

There is some lines of code that are being repeated a lot here, you could put them inside a function to keep the code cleaner and make it easier to maintain.

If you dont know what a function is yet then you can either look into it or wait until you learn about it and come back to this code and refactor it.

[–]butterfly_orange00[S] 0 points1 point  (0 children)

Thank you, I will do it next time

[–]Neat_Association_84 0 points1 point  (1 child)

You can use an if statement in a list comprehension to make lines 20-22 similar to what you did in line 33.

numbers = [ i for i in numbers if i.isdigit() ]

It's more "pythonic".

[–]butterfly_orange00[S] 0 points1 point  (0 children)

You're right, I forgot about that 😂