Friday, 27 September 2013

Printing the value of a specific key in dict

Printing the value of a specific key in dict

How do I access a variable's value?
class Example:
def __init__(self):
self.food = "Soup"
def get_food(self):
return self.food
food_dict = {
"Soup": 3,
}
x = Example.get_food
for x in food_dict.keys():
What should the next line be in order to print the value?

No comments:

Post a Comment