Новый курс! Каждый программист должен знать генеративный ИИ!
+ 2

# Why is int("3"+"4") =34

11th Jan 2017, 9:07 AM
Anuhya
20 ответов
+ 18
Both are string so it concatenates : "3" + "4" = "34" When that string is passed to int() function, it returns 34
11th Jan 2017, 9:09 AM
sharper_than_learning_curve
+ 11
it prints the character since its in quotations. take away the quotes and it'll do math
11th Jan 2017, 9:52 AM
Ahri Fox
+ 4
if you wanted to get 7 as an answer you can try print(int("3")+int("4"))
11th Jan 2017, 2:17 PM
ramzi
+ 4
"3"+"4" is passed as the argument for type conversion to int. so it first concatenates before making it into int
11th Jan 2017, 7:11 PM
Ranjith M
+ 3
bro you have added two strings "/","/" like "h"+" I"=hi
11th Jan 2017, 10:17 AM
Bruh
+ 1
"3"+"4"="34"
11th Jan 2017, 10:02 AM
Zhongchao Neil
+ 1
Because the string concat is done before the conversion to integer
11th Jan 2017, 9:02 PM
Davide Corbelletto
+ 1
If you want to print 7 you must use this code: print(3 + 4) You get 34 because it takes the strings 3 and 3 and 4 and make it together (34).
12th Jan 2017, 4:07 PM
Mostafa Kerim
+ 1
Code it like that... Int("4") +int("3")
18th Jan 2017, 9:14 PM
ali J
+ 1
i think that you have to convert each one of this variable :)
24th Jan 2017, 4:51 PM
Hesham Taha ElSaid Hassan Kamal-ElDain
+ 1
because, you in question dont use one string to program recognize a number!!! if you use inverted commas python recognize who a word and no who a number!
27th Jan 2017, 9:55 AM
João Miguel Tavares Mendes
0
because they are strings and not numbers. Strings are treated as characters and not as numbers
11th Jan 2017, 3:36 PM
Tapan Pareek
0
see inside the brackets you are combining 2 string literals and the +sign concates those literals....then after doing the work inside brackets it is converted to integer literal i.e. 34
12th Jan 2017, 1:45 AM
khateeb anwer
0
THE thing is that int() is not a value which you can simply take common like in mathematics. eg 2(3+4). Cheers !!
12th Jan 2017, 4:26 PM
aryan
0
It returns you number wit " " as a string. So: "number" + "number" is inerpreted number as a string of two numbers bonded by + sign.
27th Jan 2017, 7:21 PM
Milena
0
because they are strings, they aren't numbers.
27th Jan 2017, 11:35 PM
sashblnka
0
I tried typing int("3"+"4") in the console, but the message I got was 'no output'. Did anyone face a similar problem as well.?
27th Feb 2017, 11:45 PM