Quick question.....

Narsil featherstone80 at hotmail.com
Thu Jan 15 19:34:14 EST 2004


I tried that.  I get the following error message

Traceback (most recent call last):
  File "E:\python\fun4b.py", line 80, in ?
    menu()
  File "E:\University\python\assign4b.py", line 49, in menu
    print sum(weektotlist)
NameError: global name 'sum' is not defined

What did I do wrong?

TomN

"Batista, Facundo" <FBatista at uniFON.com.ar> wrote in message news:<mailman.370.1074115102.12720.python-list at python.org>...
> featherstone80 wrote:
> 
> #- numberlist = [10, 2, 5, 7, 3, 46, 4, 5, 87, 5]
> #- 
> #- How would I get the total, and how would I get the average?
> 
> 
> Python 2.3 (#46, Jul 29 2003, 18:54:32) [MSC v.1200 32 bit (Intel)] on win32
> ...
> >>> numberlist = [10, 2, 5, 7, 3, 46, 4, 5, 87, 5]
> >>> sum(numberlist)
>  174
> >>> len(numberlist)
>  10
> >>> sum(numberlist)/len(numberlist)
>  17
> >>> from __future__ import division
> >>> sum(numberlist)/len(numberlist)
> 17.399999999999999
> 
> .	Facundo



More information about the Python-list mailing list