← Back to Files
Question 424
Last Line First
Last Line First
Three lines read from input are written to order.txt and read back into the list lines with readlines. Loop over the list backwards using the slice lines[::-1] and print each line with its newline removed by rstrip, so the file appears in reverse order. Input: three lines, no prompt.
Expected Output:
third second first
= newline. The output ends with a newline — print one after the last line.
Hints2 available
Sign in to use hintsTopics:
FilesSlicing
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (pr, inp, def)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.