ZeroDivisionError: float division (baby steps)

Artemisio calidusdk at hotmail.com
Fri Aug 20 23:39:24 CEST 2004


"Russell Blau" <russblau at hotmail.com> wrote in message news:<2okg05Fbh7kjU1 at uni-berlin.de>...
> "Benjamin Niemann" <pink at odahoda.de> wrote in message
> news:cg3184$vbr$02$1 at news.t-online.com...
> > Artemisio wrote:
> > > I am a non programmer who just started with Python. So far I love it.
> > >
> > > I would appreciate if you could help me fix this error I get taking this
>  exercise:
> > >
> > > count= 0
> > > sum= 0.0
> > > number= 1
> > > print "Enter 0 to exit the loop"
> > >
> > > while number != 0 :
> > > number= input("Enter a number: ")
> > >
> > > count= count + 1
> > > sum= sum + number
> > >
> > > count= count -1
> > > print "The average is: ",sum/count
> > > #the error is in the above line
> > >
> > > "ZeroDivisionError: float division"
> > >
> > > Thank you in advance, Len
> > I think the two lines after input() should be indented as the belong to
> > the while loop...
> 
> Note that, even after you fix this, you will still get an error if the user
> decides to enter "0" as the first number!

Well, thank you very much for your feedback. I've sorted out now. For
some reason the last two lines were indented. Unindenting them
producted the expected behaviour.

I am actually amazed by how intuitive and readable Python coding is.
I've spent maybe 12 hours with it and I can already code small
routines of my own. I felt more frustrated last time I tried to learn
VB. I gave up. Python is my game.



More information about the Python-list mailing list