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 Errors

What is the difference between ' and " in python?

When using python I can run a script using both ' and " is there a difference that I should know about and do they perform differently?

2 Answers

Both are equal and what you use is completely up to your preference. Just try to stick to one of 'em throughout your script!

I will add that " is useful when ' is inside the string, and vice versa.

Thanks! I just want to make sure that I use Python correctly!

Myt pleasure! It was a good question. Keep coding :)

Both variants works the same way. You can use both of them, for example in a string to avoid \ symbol.

str = "Hello 'beautiful' world"
str = 'Hello "beautiful" world'
str = 'Hello \'beautiful\' world'
str = "Hello \"beautiful\" world"