+ 1
why does it produce error ?
>>>int('3.0')+int('2')
2 Answers
+ 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')
0
this is not possible in c due to typecasting