By completing this challenge you will learn how data can be stored using lists.
You will store a series of quotes in a list and append new quotes to your list.
You will also find out how to pick up a random value from a list using the random.choice() function.
In Python, a list is used to save a collection of values. For instance, to save all the different days of the week we could declare a variable called “daysOfTheWeek” and assign a list as follows (Notice the use of square brackets):
daysOfTheWeek = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
Based on this what do you think len(daysOfTheWeek) would return?
What’s about daysOfTheWeek?
In this challenge we decided to create list to store a collection of inspirational quotes.
We then randomly pick a quote from this list to display it to the end-user.
Look at this page. Update the code above to give more daily items. For instance you could:
- Store a list of science based facts and display the “fact of the day”,
- store a list of French words and display the “French word of the day”,
- store a list of maths equations (e.g. 45 + 52 = ?) and display the “Maths Challenge of the day”,