0

Why both of expressions doesnt return 5 as result, since the first one is being converted to int?

print(int("2" + "3")) --> result 23 print(int("2") + int("3")) --> result 5

16th Jul 2018, 8:41 AM
André Costa
André Costa - avatar
2 ответов
+ 5
André Costa First 2+3 as a string is done Then the string is turned into a int so the string 23 is turned into an int Remember everything within the brackets happen first This is why the strings are added then turned to int. The second way is correct as the strings are turned into int first Then thay are added to get 5
16th Jul 2018, 8:51 AM
Agent
Agent - avatar
+ 1
got it. thank you
16th Jul 2018, 10:38 AM
André Costa
André Costa - avatar