Re: ZeroDivisionError: float division (baby steps)

From: Russell Blau (russblau_at_hotmail.com)
Date: 08/19/04


Date: Thu, 19 Aug 2004 16:13:56 -0400


"Benjamin Niemann" <pink@odahoda.de> wrote in message
news:cg3184$vbr$02$1@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!

-- 
I don't actually read my hotmail account, but you can replace hotmail with
excite if you really want to reach me.


Relevant Pages

  • ZeroDivisionError: float division (baby steps)
    ... I am a non programmer who just started with Python. ... I would appreciate if you could help me fix this error I get taking this exercise: ... sum= sum + number ...
    (comp.lang.python)
  • Re: Outlook Express Corrupt dbx files
    ... I guess 5 bucks ain't so bad. ... and pay when they find something that really ... >programmer" trying to get richer. ... >> Is there any way to fix a corrupted .dbx file for free? ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)
  • Re: Notices
    ... An unchecked checkbox is not sent in $_REQUEST and if you do something with $_REQUESTyou'll get a notice. ... I'm a recovering perl programmer so conciseness is still important. ... It's a bit tedious at times to fix harmless missing index notices when you just want to test something. ...
    (comp.lang.php)
  • Re: xmlrpc, httplib and SSL
    ... the SSL builtin to Python 2.3, so the latter builds yet another ... I *am not* volunteering to fix this. ... I can't even test fixes ... I will provide moral support and the ...
    (comp.lang.python)
  • Re: mutable default parameter problem [Prothon]
    ... I love Python dearly. ... So far you have only shown me an idiom that many say should not be used. ... If I also might make a general argument for the fix then let me continue. ... Dynamic var scoping fixed another Python gotcha which doesn't break ...
    (comp.lang.python)