Skip to main content

Unit 1 · What is Python?! · Lesson 7 of 57

Silly String

MLA Format... but Python?

Let's take a step back for a second.

When we did print("Hello World!"), you may have noticed the quotation marks. Why are those there?

Well, at the end of the day, Python is just a computer program. It can't figure things out from context or use common sense. So, we use quotes to label what Python shouldn't treat as code.

We call these strings. The best way to think about it is a string of text.

  • "To be or not to be"
  • "From zero!"
  • "I love python!"

These are all examples of strings. Whenever Python sees an opening quote, it treats everything after it as plain text, not code, until it hits the closing quote.

In fact, you can use ' instead of ". Just make sure you close it with the same one you opened it with! Many people prefer ", as it looks cleaner and is more in line with other languages.

Do this lesson for real

With a free account you get the terminals, challenges and checks that go with the lessons in Intro to Python, and your progress is saved as you go. CyberAcad is a 501(c)(3) nonprofit, so there is nothing to pay.