- 1
May someone please explain this code for me?
x = 10 y = x + 6 y = int(str(y) + "4") print (y)
2 Réponses
+ 5
what is require ? Also use language name in tag .
You can solve the problem yourself by just a little bit googling for right thing .
str converts number to string i.e. "16" and when two strings are added they result in concatenation i.e. "16"+"4"="164" and int converts it back to number 164.
+ 5
I am considering it's a python language so in python str method will convert number to string so here
x = 10
y = x + 6 = 10 + 6 = 16
now here str(y) will convert 16 to string so as you know that when you add two or more string then it concatenate each other so here
str(y) + "4" = 164
now int method will convert this string 164 to integer