Today's challenge introduces iteration to you.
Santa has a list that he has created showing how much he has spent on each persons present. You can see this in the list. Part of the code has been given to you today. See below
presents = [3.99,4.99,3.50,6.90,7.90,10.99,5.8]
for i in range (len(presents)):
print (presents[i])
This code has an array called presents which is full of numbers. The for loop will go through each item in the list and get it's value by using the letter i as it's starting point. Printing will print each item it's on. You're required to work out the average spent using Python and you must use the length of the list to do this. You are also required to work out how much he has spent in total.
What does this code do?
This current code will go through each item in the list and print it out.
What do you need to do?
You need to have a variable which can be used for the total and you should work out how much Santa has spent on gifts and output it.
You will also need to make sure that you work out how much he has spent on average. You must do this by using the length of the list (see the print screen).
Requirements: -
*How much has Santa spent in total?
*What is the average he has spent?
*Output the average