+ 2

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

11th Jan 2017, 9:07 AM
Anuhya
20 Respostas
+ 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
Ahri Fox - avatar
+ 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
ramzi - avatar
+ 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
Ranjith M - avatar
+ 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
Zhongchao Neil - avatar
+ 1
Because the string concat is done before the conversion to integer
11th Jan 2017, 9:02 PM
Davide Corbelletto
Davide Corbelletto - avatar
+ 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
Mostafa Kerim - avatar
+ 1
Code it like that... Int("4") +int("3")
18th Jan 2017, 9:14 PM
ali J
ali J - avatar
+ 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
Hesham Taha ElSaid Hassan Kamal-ElDain - avatar
+ 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
JoĆ£o Miguel Tavares Mendes - avatar
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
Tapan Pareek - avatar
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
khateeb anwer - avatar
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
sashblnka - avatar
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
aditya bhardwaj
aditya bhardwaj - avatar
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.? " you have to typing it like that print(int(("3")+("4")))
20th May 2017, 4:46 AM
Hesham Taha ElSaid Hassan Kamal-ElDain
Hesham Taha ElSaid Hassan Kamal-ElDain - avatar
0
when they are in quote the will consider as string then their addition is like string addition
2nd Aug 2017, 2:35 AM
Rajesh Kumar R
Rajesh Kumar R - avatar
0
As the first operation is to evaluate the brackets ("3" + "4") which results in a concatenation and after that result of it ("34") goes as an input to the int function
8th Aug 2020, 9:02 AM
Saurav Sharma
Saurav Sharma - avatar