Exercises for Lesson 14

Back to Lesson 14

Exercise 1: Reading from a CSV file

Assume you have a file names.csv with the following format:

Sadie,15
Hobbes,11
Lulu,11

Write a program that reads in the file and prints a message for each user:

>>> main()
Hi Sadie, you are 15 year(s) old.
Hi Hobbes, you are 11 year(s) old.
Hi Lulu, you are 11 year(s) old.

If you have time, think about how you can tailor the message to print “year” or “years”, as appropriate.

Back to Lesson 14