Re: ZeroDivisionError: float division (baby steps)

From: Benjamin Niemann (pink_at_odahoda.de)
Date: 08/19/04


Date: Thu, 19 Aug 2004 22:05:48 +0200

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...



Relevant Pages

  • Re: A design problem
    ... programmer. ... through the loop, read the data for one of the processes, open its ... go along and then dump them out to disk at the end of the Python ... Optionally flush the file for data integrity ...
    (comp.lang.python)
  • Re: ZeroDivisionError: float division (baby steps)
    ... >> I am a non programmer who just started with Python. ... > But I can't resist giving advice. ... > Instead of using sentinel values, it's possible to put the loop ...
    (comp.lang.python)
  • Re: Python or PHP?
    ... If it's one of the things for which Python ... every language here and there more ways to do something. ... you make Perl more complicated than it is:-D. ... Not the programmer. ...
    (comp.lang.python)
  • Re: Attack a sacred Python Cow
    ... Prove that implicit self is a good idea -- ... The issue here has nothing to do with the inner workings of the Python ... needs to be supplied by the programmer. ... It just occurred to me that Python could allow the ".member" access ...
    (comp.lang.python)
  • Re: True inconsistency in Python
    ... >Explicit comparison with the true constant ... In most languages (including Python), ... Now of course any idiot C programmer knows that these two are ...
    (comp.lang.python)