I'm a beginner in Python and I started messing around with it. I have this simple code:
def guess_number(Name,Gender):
if Gender=='Male':
Title='Mr.'
else:
Title='Ms.'
number=int(raw_input("Hello " + Title + Name + ", guess what my favorite number is between 1-10"))
if number==4:
print number
print "That's my favorite number!"
else:
print number
print "Try Again!"
return number
choice_dict=dict([(1,0),(2,0),(3,0),(4,0),(5,0),(6,0),(7,0),(8,0),(9,0),(10,0)])
for i in range(10):
guess_number("Noam","Male")
choice_dict[number]=choice_dict[number]+1
print choice_dict[1], choice_dict[2], choice_dict[3], choice_dict[4], choice_dict[5], choice_dict[6], choice_dict[7], choice_dict[8], choice_dict[9], choice_dict[10]
It's a simple process where in a function called "guess_number" it asks a person for a certain number between 1-10. It repeats the function 10 times and for each number chosen it will add +1 to the number in a dictionary, at the end it prints how many times was each number chosen.
For some reason I don't understand it tells me that "number" is not defined even though I returned the variable "number" in the function "guess_number".
What is missing?