Returning a result from 3 items in a list

Cai Gengyang gengyangcai at gmail.com
Tue Nov 24 05:47:44 EST 2015


Yup, thanks a lot ... it works now !

>>> results = {
  "gengyang": 14,
  "ensheng": 13,
  "jordan": 12
  }
>>> results["jordan"]
12


On Tuesday, November 24, 2015 at 6:40:26 PM UTC+8, Peter Otten wrote:
> Cai Gengyang wrote:
> 
> > Strange, it gives me an error message when i type result["jordan"] or
> > result[max(result)] though :
> > 
> >>>> results = {
> >   "gengyang": 14,
> >   "ensheng": 13,
> >   "jordan": 12
> > }
> > 
> >>>> result["jordan"]
> > Traceback (most recent call last):
> >   File "<pyshell#27>", line 1, in <module>
> >     result["jordan"]
> > NameError: name 'result' is not defined
> 
> Yeah, the error message really should be
> 
> "NameError: name 'result' is not defined; did you mean 'results'?"
> 
> ;)



More information about the Python-list mailing list