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 (2015) Python for Beginners Create a variable

how to write a variable ?

how to write a variable ?

variable.py
'name = "Salim"'

3 Answers

You are close! It's just that you shouldn't put quotes around the whole line of code. You only need quotes for strings (text data are basically strings).

Take a look:

Keep in mind that in Python everything after the hash sign # is NOT run by Python. Python just ignores everything after the hash sign in a program. It is just used for human-reading. They are called Comments in Python.

'name = "Salim"'  # Invalid code, will cause Syntax Error

name = "Salim"  # Code that will pass!

I hope this helps. ~Alex

gg

sascha101
sascha101
1,208 Points

Salim,

to create the variable 'name' just do what you already posted in your question:

name = "Salim" is the correct syntax