0
Converting var to int
x = "2" int(x) print( x + 2 ) why does this input produce an error?
4 Respostas
+ 9
x = "2"
x = int(x)
print( x + 2 )
...see why...
+ 2
You can also do print(int(x))
+ 1
ah, that explains it, thanks!
+ 1
this is because you have not assigned a variable for int(x) if you assign x="2" and then will print x+2 it will obviously show error
you should define a variable y=int(x) then print y+2 it will show correct output