0

The numbers in quotes is supposed to be strings?

28th Jun 2016, 3:03 AM
Akash Desarda
Akash Desarda - avatar
6 Respuestas
+ 3
Yes they are for instance: a = "4" b = "3" a + b = "43" # concatenation but if you want to add rather though being strings: c = int(a + b) # result of concatenation converted to an integer and save in the variable c c = int(a) + int(b) # this converts strings before adding to produce integer c = 7 # for the two methods above
28th Jun 2016, 5:26 AM
Benneth Yankey
Benneth Yankey - avatar
+ 1
yes
28th Jun 2016, 4:02 AM
Nishant Sardana
Nishant Sardana - avatar
+ 1
sorry how does c=int (a+b) result in c=7? isn't it still 43? sorry I've just started python
28th Jun 2016, 6:41 AM
정진하
정진하 - avatar
0
yep int(a+b) =43
28th Jun 2016, 6:44 AM
Nishant Sardana
Nishant Sardana - avatar
0
ooh thanks Nishant
28th Jun 2016, 6:45 AM
정진하
정진하 - avatar
0
yes sure you are right, c=int(a+b) result in c= 43 but the other results in c=7 thanks
28th Jun 2016, 6:46 AM
Benneth Yankey
Benneth Yankey - avatar