Problem

Given a test file named “test.txt” containing the following three lines:Line OneLine TwoLi...

Given a test file named “test.txt” containing the following three lines:

Line OneLine TwoLine Three

Consider the following code:

    someFile = open('test.txt', 'r')    for line in someFile: # Loop 1           print line    for line in someFile: # Loop 2           print line

(a) What will be printed by Loop 1?

(b) What will be printed by Loop 2?

(c) How can you modify the code so that both Loop 1 and Loop 2 print the same thing (other than having them both print nothing)?

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 14
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT