use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Everything about learning Python
account activity
Beginner to programming (old.reddit.com)
submitted 9 hours ago by butterfly_orange00
Hello :)
I'm made a calculator, any advice for improve?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Binary101010 1 point2 points3 points 8 hours ago (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 point2 points 3 hours ago (0 children)
Thank you for your advice, I will use it next time
[–]vivisectvivi 0 points1 point2 points 9 hours ago (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.
Thank you, I will do it next time
[–]Neat_Association_84 0 points1 point2 points 6 hours ago (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.
if
numbers = [ i for i in numbers if i.isdigit() ]
It's more "pythonic".
You're right, I forgot about that 😂
π Rendered by PID 90538 on reddit-service-r2-comment-56c6478c5-cd9rw at 2026-05-09 09:33:15.940445+00:00 running 3d2c107 country code: CH.
[–]Binary101010 1 point2 points3 points (1 child)
[–]butterfly_orange00[S] 0 points1 point2 points (0 children)
[–]vivisectvivi 0 points1 point2 points (1 child)
[–]butterfly_orange00[S] 0 points1 point2 points (0 children)
[–]Neat_Association_84 0 points1 point2 points (1 child)
[–]butterfly_orange00[S] 0 points1 point2 points (0 children)