0

I'm trying to write a program which asks for the number of animals and then the name and the population of each animal. I want to get it to add the population of each animal but I having trouble getting the variables from the dictionary and adding them.

This is what I have so far.

animals={}
x=input("How many animals?")
loop=0
while loop!=x:
    animal=raw_input("What is the animal called?")
    popul=input("what is the population?")
    animals[animal]=popul
    loop=loop+1
print "the total number of animals is"
2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by Gribouillis
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.