You are on page 1of 3

Exercise

Question: Consider the following list:

ids=["B3","\nB4","\nB5","\nB6"]

Then, write a program that produces a text file which looks like this:

TIP: If you don’t know where to start, please scroll to the next page for some hints.
HINT 1: Consider using the with method to create the file and the for loop to write the list items inside
the file.

TIP: Try to solve the exercise thinking of the above hint. Excellent if you solve it. If that hint is not
enough, more hints await for you in the next page. Keep scrolling!
HINT 2: You should first create a file using the with method, and while the file is opened, you should
create a loop that iterates through the list items in the next line after with. Then, you should apply the
write method to the opened file under the for line.

TIP: If you are almost there, but something seems to be not working, then please see the next PDF
lecture for the solution.

You might also like