Defining multiple functions in Python -
i'm new writing code, , i'm working through "learn python hard way." want define both personname , hoarder following result:
fred had 45 cats.
bill had 20 dogs.
lot of animals.
find therapist!
def personname(name1, name2): def hoarder(number_of_cats, number_of_dogs): print "%r had %d cats." % (name1, number_of_cats) print "%r had %d dogs." % (name2, number_of_dogs) print "that lot of animals." print "find therapist!" print person("fred", "bill") hoarder(45,20)
def personname(name1, name2): def hoarder(number_of_cats, number_of_dogs): print "%r had %d cats." % (name1, number_of_cats) print "%r had %d dogs." % (name2, number_of_dogs) print "that lot of animals." print "find therapist!" hoarder(45,20) personname("fred", "bill") 'fred' had 45 cats. 'bill' had 20 dogs. lot of animals. find therapist!
if want define 2 function, need write them above. please pay attention scope of function.
Comments
Post a Comment