Hey so Im a beginner, and I need some help.
My professor gave us this code:
def average(list):
total = 0.0
for number in list:
total += number
return total / len(list)
Then, he asked us to rewrite that program so that it uses a while loop instead.
So far I tried and got this...
def average(list):
total = 0.0
i = 0
while (I < len(list)):
total += list
i += 1
return i
When I tried to run that, I kept getting the wrong answer for any list I tried. :/
If you could please help me, i'd be forever grateful :D