Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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.