Integers and Strings | SoloLearn: Learn to code for FREE!

+1

Integers and Strings

If I type print(int("5" + "5")) it become 55 and not 10 ? I thought putting int first will make it into an int

4/12/2020 5:53:18 AM

M.O.HONOR

5 Answers

New Answer

+6

It witll return 55 because it runs first the codes in the bracket. If you want it to return 10 you should run the code like this print(int("5")+int("5")) this will allow to first transform the strings into integers and then sum the integers.

+3

Inside items are taken as string not as integers because of ("" ) marks

+3

If it will be int( 5 + 5 ) this will result in 10

+2

First it will evaluate what is inside the brackets so "5"+"5" becomes 55 as it is a string then I will convert 55 to integer

0

Alright thx