Care to explain? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Care to explain?

Even if your strings contain numbers, they are still added as strings rather than integers. Adding a string to a number produces an error, as even though they might look similar, they are two different entities. Source - python 3 tutorial > basic concepts > concatenation

16th May 2019, 7:34 AM
ERROR_404
ERROR_404 - avatar
6 Answers
+ 2
2 + e == 2e this is error "2" + "2" == 22 this is string 2 + 2 == 4 this is integer sum so integer + string gives error string + string makes a new string like StringString also keep in mind that every string is an array of letters. "Word" is ["W","o","r","d"] but integer is not array 234 is not [2,3,4]
16th May 2019, 7:40 AM
Melih Melik Sonmez
Melih Melik Sonmez - avatar
+ 1
Is "2" + "e" possible?
16th May 2019, 7:42 AM
ERROR_404
ERROR_404 - avatar
+ 1
16th May 2019, 7:44 AM
ERROR_404
ERROR_404 - avatar
+ 1
Titus Mathew "2" + "e" will result as "2e" as they are concatenated as strings
16th May 2019, 12:25 PM
Trigger
Trigger - avatar
+ 1
Thomas Williams I figured that out but thanks man 👌
16th May 2019, 1:09 PM
ERROR_404
ERROR_404 - avatar
0
you are welcome
16th May 2019, 8:10 AM
Melih Melik Sonmez
Melih Melik Sonmez - avatar