In the following program, what is the "values" function?

for tank in tanks.values():
    if tank.alive:
        print tank.name, "is the winnter!"
        break

I looked it up using Wing IDE and this is what I found.

def values(self, arg):
    """ D.values() -> list of D's values """
    return []

Thanks for any and all replies.

Recommended Answers

All 3 Replies

Dictionary has keys() and values()
You dont show all code.

Example.
>>> tanks = {'tiger': 'a55', 'trunk': 'f77'}
>>> for tank in tanks.values():
        print tank    

a55
f77

>>> for tank in tanks.keys():
        print tank
    
tiger
trunk

#--------
>>> dir(tanks)  #this show methods under dictionary

Thanks, some how that went right over my head while reading the my python book. But showing them one right on top of the other really cleared that up for me. Thanks.

Could you please mark this thread as solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.