{"id":"printing-several-lines","slug":"several-lines","title":"Several lines, in order","text":"A program usually has many commands, each on its own line. Python runs them from top to bottom, one after another, and each `print` prints one line:\n\n```python\nprint(\"3\")\nprint(\"2\")\nprint(\"1\")\nprint(\"Liftoff!\")\n```\n\n```output\n3\n2\n1\nLiftoff!\n```\n\nSwap two of the lines and the countdown is in the wrong order: the computer does exactly what the commands say, in the order they are written.\n\n### The output has to match exactly\n\nThe checks on this site compare what your program prints with the expected output, character by character. `Liftoff!` and `liftoff!` are different, and so are `Hello, world` and `Hello,world`. The only things ignored are spaces at the very end of a line and empty lines at the very end of the output. Real programs are held to the same standard: another program reading your output won't guess what you meant.\n\n### An empty line\n\n`print()` with nothing inside the parentheses prints an empty line, which is handy for leaving space between parts of the output:\n\n```python\nprint(\"Part one\")\nprint()\nprint(\"Part two\")\n```\n\n```output\nPart one\n\nPart two\n```\n","task":"The program prints the first line of a short rhyme. Add the two missing lines so it prints exactly:\n\n```\nLine by line the program goes,\ntop to bottom, as it flows,\nprint shows all that Python knows.\n```\n","kind":"code","seed":"print(\"Line by line the program goes,\")\n","solution":"print(\"Line by line the program goes,\")\nprint(\"top to bottom, as it flows,\")\nprint(\"print shows all that Python knows.\")\n","hints":["Each line of the rhyme needs its own `print(\"...\")` command, below the first one.","Copy the text exactly, including the commas, the full stop and the small first letters."],"tests":[{"name":"Output","stdin":"","expect":"Line by line the program goes,\ntop to bottom, as it flows,\nprint shows all that Python knows.","hidden":false}],"require":[{"pattern":"\\bprint\\s*\\(","min":3,"max":3,"message":"Print each line of the rhyme with its own `print`, three in all."}],"forbid":[],"more":[{"task":"The morning routine got shuffled. Put the four commands in the right order so the program prints:\n\n```\nWake up\nBrush teeth\nEat breakfast\nStart coding\n```\n","kind":"code","seed":"print(\"Eat breakfast\")\nprint(\"Wake up\")\nprint(\"Start coding\")\nprint(\"Brush teeth\")\n","solution":"print(\"Wake up\")\nprint(\"Brush teeth\")\nprint(\"Eat breakfast\")\nprint(\"Start coding\")\n","hints":["The commands run from top to bottom, so the line that should be printed first goes at the top.","Move whole lines. On a phone: select a line, cut it, tap where it should go and paste."],"tests":[{"name":"Output","stdin":"","expect":"Wake up\nBrush teeth\nEat breakfast\nStart coding","hidden":false}],"require":[{"pattern":"\\bprint\\s*\\(","min":4,"max":4,"message":"Keep the four `print` commands and only change their order."}],"forbid":[]},{"task":"Print this ticket exactly, spaces and the empty line included:\n\n```\n==================\n  PYTHON ARENA\n\n  Admit one\n==================\n```\n","kind":"code","seed":"print(\"==================\")\n","solution":"print(\"==================\")\nprint(\"  PYTHON ARENA\")\nprint()\nprint(\"  Admit one\")\nprint(\"==================\")\n","hints":["The spaces at the start of a line are part of the text, so they go inside the quotes.","The empty line is `print()`, with nothing between the parentheses.","The ticket has five lines, so the program has five `print` commands."],"tests":[{"name":"Output","stdin":"","expect":"==================\n  PYTHON ARENA\n\n  Admit one\n==================","hidden":false}],"require":[],"forbid":[]}]}