Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Python Basics Meet Python Variables

Lorrian Landicho
Lorrian Landicho
278 Points

why is the string 11 assigned to first_name variable without quotation marks?

first_name = 11

2 Answers

11 in this case is not a string, because there is no quotation marks. It is indeed a number, as Kyle Vandeven said, which are called integers in math (and sometimes ints in programming). Integers do not have quotation marks, because if they did have them, Python would think they are strings. (The string "11" isn't the same as the number 11!)

Strange things can happen when you put quotation marks around integers:

>>> 11 + 11
>>> '11' + '11'
>>> 11 + '11'

The last line (11 + '11') causes this error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for +: 'int' and 'str'

Adding strings and numbers doesn't make sense to Python, so it throws up its hands and responds with an error!

It isn't a string. The variable first_name is by definition of type Int.