+ 1

This program runs fine in python 3 but not in python 2 . Why???

https://code.sololearn.com/cuZFcA0dvQBz/?ref=app

10th Nov 2018, 5:13 AM
partha
partha - avatar
3 ответов
+ 4
Built-in input function behaviour is different between py2 and py3. In py2, it read input, try to evalute the expression with eval function and return it, then if your input is an number, it would return an int number. In py3 instead, it return simply the input like string. Because this, and because you compare his return value with strings, your "if" conditions never will be true (a int is not a string) in py2 but work correctly in py3
10th Nov 2018, 5:52 AM
KrOW
KrOW - avatar
+ 1
thanks KrOW
10th Nov 2018, 6:18 AM
partha
partha - avatar
0
👍👍👍
10th Nov 2018, 6:19 AM
KrOW
KrOW - avatar