0
What if you write: x = 12 \n x = x + 'string' \n print (x) ; is the output then "12string"?
Because it said that variables can be strings and integers. Can they be both at the same time?
2 odpowiedzi
+ 1
12 is a integer
'12' is a string...
int('12') is an intger similar to 12( string to int conversion)
str(12) is a string similar to '12'(int to string conversion)
x=12
x=x+'string'
now x is int value
'string' is string
2 diff type of variables cant be added...
WILL SHOW ERROR
u can dooo
x=12
x=str(x) + 'string'
then its 12string as output
+ 5
x="12"
x=x+"string"
print(x)
will be 12string
otherwise you will get an error