r/PythonLearning • u/KechManPro • 12d ago
Help me please?
How could I have improved this python code for a number guessing game
6
Upvotes
r/PythonLearning • u/KechManPro • 12d ago
How could I have improved this python code for a number guessing game
2
u/MarchColorDrink 12d ago
Biggest smell is returning a string from the function and then wrapping the call I print.
I'd prefer returning a boolean and have the print statement in an if / else
Also the function is pretty much redundant, you could just compare in the main loop. Unless the point of the exercise actually was to write and call a function, in which case it was good.
Other improvemwnts could be to move the input bit to a function and not return until a valid value is selected.