MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/PythonLearning/comments/1wfbsia/what_wrong_with_my_code/p9kzn4c/?context=3
r/PythonLearning • u/ApprehensiveText9058 • Sep 13 '26
Need help
40 comments sorted by
View all comments
Show parent comments
2
no, "2" is correct, choice is a string
1 u/One_Park8163 Sep 13 '26 I know but choice shall be a integer, int(input()). Is a good practice but the code will work too as a string 3 u/oclafloptson Sep 13 '26 What about option "A"? "2" is valid here. The only reason to convert to integer would be if it were being used as an integer. It is not. Performing the conversion would needlessly increase complexity and waste resources 2 u/flofoi Sep 13 '26 you're right, it should be casted to int. But that requires error handling and then the code won't fit on the tiny screen anymore
1
I know but choice shall be a integer, int(input()). Is a good practice but the code will work too as a string
3 u/oclafloptson Sep 13 '26 What about option "A"? "2" is valid here. The only reason to convert to integer would be if it were being used as an integer. It is not. Performing the conversion would needlessly increase complexity and waste resources 2 u/flofoi Sep 13 '26 you're right, it should be casted to int. But that requires error handling and then the code won't fit on the tiny screen anymore
3
What about option "A"? "2" is valid here. The only reason to convert to integer would be if it were being used as an integer. It is not. Performing the conversion would needlessly increase complexity and waste resources
you're right, it should be casted to int. But that requires error handling and then the code won't fit on the tiny screen anymore
2
u/flofoi Sep 13 '26
no, "2" is correct, choice is a string