MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/PythonLearning/comments/1n18y5x/help/nb0dyc2/?context=3
r/PythonLearning • u/Avinandanm • Aug 27 '25
Where is the problem
22 comments sorted by
View all comments
3
Here are my 2c:
start the loop with 2, instead of 1 because n % 1 is always 0.
indent the break inside the if-statement, i.e. four spaces to the right, so that the loop breaks only if the if’s condition evaluates to True.
[a nitpick] use int(…) instead of eval(…) since eval(…) does more than you probably need in the program.
Enjoy your coding journey!
1 u/thw31416 Aug 31 '25 The eval is pretty scary there, executing user input as code. Someone putting in "import os; os.remove(...)" might be able to do quite some damage...
1
The eval is pretty scary there, executing user input as code. Someone putting in "import os; os.remove(...)" might be able to do quite some damage...
3
u/timheiko Aug 27 '25
Here are my 2c:
start the loop with 2, instead of 1 because n % 1 is always 0.
indent the break inside the if-statement, i.e. four spaces to the right, so that the loop breaks only if the if’s condition evaluates to True.
[a nitpick] use int(…) instead of eval(…) since eval(…) does more than you probably need in the program.
Enjoy your coding journey!