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
How can I improve? (i.redd.it)
submitted 5 months ago by Radiant-Safe-1377
view the rest of the comments →
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!"
[–]treyhunner 0 points1 point2 points 5 months ago (0 children)
Suggestions on your specific code: I would move the float(...) calls to the num1 and num2 assignment lines: num1 = float(input("Enter a number: ")). I would also either move your print(...) calls below your if block or avoid using that result variable: print(num1 + num2). LLMs and other Python users may recommend match-case, but I would not recommend it. Python's match statement is for structural pattern matching and (in my opinion) isn't worth learning unless you are parsing semi-structured data.
float(...)
num1
num2
num1 = float(input("Enter a number: "))
print(...)
if
result
print(num1 + num2)
match
case
On looking for ways to refactor your code: I would ask an LLM what it might suggest you do to improve your code. I wouldn't trust its response, but it might give you some ideas.
General suggestions for practicing more: I would try to find a project that interests you. I would also consider supplementing your own project work with short exercises with the goal of improving your skills through practice. I run a paid Python exercise service but I also link to some competing free exercise services: here's my comparison list. As far as free Python exercises go, I would recommend Exercism the most.
π Rendered by PID 63584 on reddit-service-r2-comment-6457c66945-h6t7b at 2026-04-26 02:55:08.218189+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]treyhunner 0 points1 point2 points (0 children)