{"id":"printing-quotes-and-comments","slug":"quotes-and-comments","title":"Quotes and comments","text":"Python accepts strings in single quotes `'` as well as double quotes `\"`. Both mean the same, as long as the string starts and ends with the same kind. That comes in handy when the text itself has quotes in it:\n\n```python\nprint('She said \"hi\" and left.')\nprint(\"It's a good day.\")\n```\n\n```output\nShe said \"hi\" and left.\nIt's a good day.\n```\n\nThe first string is in single quotes, so the double quotes inside it are just characters. The second is in double quotes, so the apostrophe in `It's` doesn't end it.\n\n### Comments\n\nA line that starts with `#` is a **comment**. Python skips it completely: comments are notes for the people who read the code. A comment can also come after the code on a line; everything from the `#` to the end of that line is skipped:\n\n```python\n# How many eggs the bakery needs this week\nprint(\"Eggs needed:\")\nprint(12 * 6)  # 12 cakes with 6 eggs each\n```\n\n```output\nEggs needed:\n72\n```\n\nProgrammers also use `#` to switch a line off for a moment without deleting it. This is called **commenting out** a line.\n","task":"The program should print the line below, double quotes included. Change the program so it works.\n\n```\nThe sign said \"Keep out\" in red letters.\n```\n","kind":"code","seed":"print(\"The sign said \"Keep out\" in red letters.\")\n","solution":"print('The sign said \"Keep out\" in red letters.')\n","hints":["As it is, the `\"` before `Keep` ends the string, and Python can't read the rest of the line.","Put the whole text in single quotes `'` instead, so the double quotes inside it are just characters."],"tests":[{"name":"Output","stdin":"","expect":"The sign said \"Keep out\" in red letters.","hidden":false}],"require":[],"forbid":[],"more":[{"task":"Write a program that prints this tip for new programmers, exactly as it is:\n\n```\nTo greet, type print(\"Hi\") and press Run.\n```\n","kind":"code","seed":"# Print the tip shown in the task.\n","solution":"# Print the tip shown in the task.\nprint('To greet, type print(\"Hi\") and press Run.')\n","hints":["The text to print contains double quotes, so put the whole text in single quotes.","The program is one `print` whose string starts and ends with `'`: `print('To greet, ...')`. Only the outer `print` runs; the `print(\"Hi\")` inside the quotes is just text."],"tests":[{"name":"Output","stdin":"","expect":"To greet, type print(\"Hi\") and press Run.","hidden":false}],"require":[],"forbid":[]},{"task":"The program prints a test message that shouldn't be there any more. **Comment out** that line (don't delete it), so the program prints only:\n\n```\nWelcome!\nHave a nice day.\n```\n","kind":"code","seed":"print(\"Welcome!\")\nprint(\"TEST: does this line show up?\")\nprint(\"Have a nice day.\")\n","solution":"print(\"Welcome!\")\n# print(\"TEST: does this line show up?\")\nprint(\"Have a nice day.\")\n","hints":["A line that starts with `#` is skipped by Python.","Put a `#` at the very start of the test line: `# print(\"TEST: ...\")`."],"tests":[{"name":"Output","stdin":"","expect":"Welcome!\nHave a nice day.","hidden":false}],"require":[{"pattern":"#\\s*print\\(\\s*\"TEST","raw":true,"message":"Keep the test line in the program, but commented out with `#` in front of it."}],"forbid":[]}]}