0

numeric type conversion

I find that Int(x) can't really change the type of x, I need to create a new variable to save it .It same as before when I print it again

11th Dec 2017, 4:12 PM
Dyea
Dyea - avatar
1 Antwort
+ 1
x = str(input( )) #storing input as string y = int(x) + 2 print(y) The need of creating a new variable is imminent. But it still works Or you can simply print what you want print(int(x) + 2) This way, you don't need to create anything new
11th Dec 2017, 9:07 PM
Jonathan Álex
Jonathan Álex - avatar