0

why print("2"+"5"==5*5) is false?

25th Jan 2017, 2:56 PM
dipanshu
3 Antworten
+ 6
The left-hand term is "25", which is a string, while the right-hand term is 25, which is an int.
25th Jan 2017, 3:23 PM
Álvaro
+ 1
The correct setence is ("2"+"5"==str(5*5))
25th Jan 2017, 5:17 PM
José Angel Martínez Socarrades
José Angel Martínez Socarrades - avatar
0
When you evaluate "25" with 25 you are for sure going to get a false value. Because "2"+"5" is a string value, whereas 5*5(25) is an int value. If you compare int with string then it will obviously end up in False result. Hence write str before 5*5, i.e. print ("2" + "5" == str(5*%)), now here, both the values are string. Ans thus produces True
27th Feb 2017, 11:48 AM
Akhil Haridasan
Akhil Haridasan - avatar