Python Python Basics (2015) Python Data Types Strings

difference between quote marks

favourite_number="90"

print(favourite_number) 90 favourite_number+2 Traceback (most recent call last): File "<pyshell#30>", line 1, in <module> favourite_number+2 TypeError: must be str, not int

why am i getting this error

1 Answer

Steven Parker
Steven Parker
201,320 Points

Without seeing more of the code for context, this is a bit of a guess. But it could be that "favourite_number" should be a number instead of a string. Putting "30" in quotes makes it a string — without the quotes it would be a number.