+ 1

why does it produce error ?

>>>int('3.0')+int('2')

22nd Feb 2017, 11:07 AM
Aviv
Aviv - avatar
2 odpowiedzi
+ 3
"int" will cast/convert integer looking strings to int type. "3.0" does NOT look like an int, so will not convert. You can make it work using float... e.g. float ('3.0') + float ('2') float ('3.0') + int ('2')
22nd Feb 2017, 11:22 AM
Jehad Al-Ansari
Jehad Al-Ansari - avatar
0
this is not possible in c due to typecasting
22nd Feb 2017, 11:41 AM
Sandip