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.

I have no idea :/ Everything I've tried so far doesn't give me the right answer.

If you could please help me, I'd be forever grateful

def average(L):
    while i<len(L):
    return total/len(L)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.