+ 2

Why isn't x getting assigned?

I did this code: https://code.sololearn.com/cDt908Hq0iXt/?ref=app it's giving me some error. I don't get it. any idea how to get it running?

12th Sep 2017, 3:37 PM
srihitha reddy
srihitha reddy - avatar
4 Réponses
+ 4
On line 3, the print statement outputs string data. the value you are giving it is an integer value trying to add into a string. You either need to convert it to a string str(x) or use a comma in the print statement. The print function can auto convert data types if they're not in the same argument (comma separation) as a different data type. For example: print(str(x) + " is the value") or print(x, "is the value")
12th Sep 2017, 3:46 PM
Sapphire
+ 3
you are trying to add a string and an int
12th Sep 2017, 3:40 PM
Enzo
Enzo - avatar
0
Well my answer was the same as theirs so: what they said.
12th Sep 2017, 3:53 PM
sproutecks25
sproutecks25 - avatar