r/PythonLearning • • Sep 13 '26

Help Request What wrong with my code

Post image

Need help

70 Upvotes

40 comments sorted by

View all comments

0

u/One_Park8163 Sep 13 '26

You shouldn't put the : after the if, i explain: you wrote if: choice=='2': that will be a sintax error. The : shall be after the 2, and moreover. The 2 shall be an integer, not a string. I hope this help you

2

u/flofoi Sep 13 '26

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