# Python reading from a file: Try it
# lists to store jobs read from todo.csv
jobs_to_do = []
jobs_done = []
print("To Do List:")
# read data from file
with open("todo.csv") as f:
contents = f.read()
lines = contents.split("\n")
for line in lines:
number, task, done = line.split(",")
if "y" in done:
jobs_done.append(task)
else:
jobs_to_do.append(task)
# display jobs marked as done already (y)
print("Jobs I've done already:")
for job in jobs_done:
print("✔", job)
# display jobs marked as not yet done (n)
print("Jobs I still need to do:")
for job in jobs_to_do:
print("✘", job)
# Challenges:
# 1) Add another job to todo.csv
# 2) Make a variable called remaining_jobs which stores the number of jobs which haven't been done yet
# 3) Make a variable called total_jobs which stores the total number of jobs (done or not done yet)
# Python reading from a file: Try it
# lists to store jobs read from todo.csv
jobs_to_do = []
jobs_done = []
print("To Do List:")
# read data from file
with open("todo.csv") as f:
contents = f.read()
lines = contents.split("\n")
for line in lines:
number, task, done = line.split(",")
if "y" in done:
jobs_done.append(task)
else:
jobs_to_do.append(task)
# display jobs marked as done already (y)
print("Jobs I've done already:")
for job in jobs_done:
print("✔", job)
# display jobs marked as not yet done (n)
print("Jobs I still need to do:")
for job in jobs_to_do:
print("✘", job)
# Challenges:
# 1) Add another job to todo.csv
# 2) Make a variable called remaining_jobs which stores the number of jobs which haven't been done yet
# 3) Make a variable called total_jobs which stores the total number of jobs (done or not done yet)
Write each prediction of what the program will output.
You can also predict variable values e.g. a = 10
This code has been sabotaged with some common mistakes. Can you find and fix them all?
Click on the button to add 5 more errors to the code
You get more points for each python skill you use from the keywords section
Click on "tests" to see a description of which python skills to aim for and keep track of which ones you've already used