There is no better way to bring in the Christmas spirit then singing some Christmas songs. Today's challenge will make use of lists again.
You're also going to learn a new skill which will do a while loop.
You are required to use a list of the lyrics from the 12 days of Christmas.
days_list = ['And a Partridge in a Pear Tree!','Two Turtle Doves','Three French Hens','Four Calling Birds','Five Golden Rings','Six Geese a Laying','Seven Swans a Swimming','Eight Maids a Milking','Nine Ladies Dancing','Ten Lords a Leaping','Eleven Pipers Piping','12 Drummers Drumming']
Each item in the list starts at zero - Remember that this is how array's / list's work.
REQUIREMENTS: -
Use a while loop
Ask for the day of Christmas between 1-12
Cast it (have you used the correct data type)
If the person types in a number, it should pick the item from the list using that number.
If the person types in the number 0, the program should break (see the example pictures)
hint - > days_list[day-1]
Our reason for subtracting one from the number they type is is because all list's start at zero.....
While Conditions: -
When programming, we can set up loops that will check conditions until something is True or False. The example code below will create an indefinite loop. This loop will continue looping while the person is over the age of 18. Think about how you could apply this to this weeks problem.
while True:
age = int(input("What is your age?"))
if age >= 18:
print("you can watch the movie")
else:
print("Sorry you're not allowed to watch this movie")
break