How to spot 1+1=11 or 1+1=2 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to spot 1+1=11 or 1+1=2

Well when i started doing python course where was print("1"+"1")When can i know that it is 2 or 11?This really confuses me

10th Sep 2017, 12:27 PM
MW Michal
MW Michal - avatar
3 Answers
+ 2
If it is in " " , it is a string. adding strings in python places one following the other. This is why "1"+"1" = 11.. It's not really the number 11, it is the string "11". "1"+"1" = "11" .. Strings 1+1=2 .. integers
10th Sep 2017, 12:53 PM
LordHill
LordHill - avatar
0
1+"1"= Error !
10th Sep 2017, 1:58 PM
Zit Zittoun
Zit Zittoun - avatar
0
ok i know now thx!
10th Sep 2017, 7:26 PM
MW Michal
MW Michal - avatar