+ 1
Understanding y = int(str(y)
x = 5 y = x + 3 y = int(str(y) + "2") I know the answer is 82. But I get the same answer if I remove the int() and just use str(). Example: y = str(y) + "2") Why does the code use this?
2 ответов
+ 6
Try running this to help understand
x = 5
y = x + 3
y = int(str(y) + "2")
print(y,'is',type(y))
z = str(y) + '2'
print(y,'is',type(z))
+ 5
In python strings are printed to the console without quotes that's why it looks identical. You should check documentation about type conversion and base types for better understanding