[Tutor] Virtual pet cat program

Prasad, Ramit ramit.prasad at jpmorgan.com
Wed Jan 18 00:51:47 CET 2012

>As you can see, no matter how many times I 'feed' the cat, its always hungry. Can someone please tell me why it wont update?

>while choice != "0":
>        print("What would you like to do? (Enter 1 to feed the cat, enter 2 to play with the cat, enter 3 to leave the cat to rest or press 0 to exit the program.")
>        choice = input(">")
>        if choice == "1":
>                user_cat.eat
>                print(user_cat)
>        elif choice == "2":
>                user_cat.play
>                print(user_cat)
>        elif choice == "3":
>                user_cat.rest
>                print(user_cat)

You are not calling the function, just referring to it. 

>>> user_cat.eat
<bound method Cat.eat of <__pieshell__.Cat object at 0x095E7C10>>

You should be calling user_cat.eat() or user_cat.eat( 10 ) to actually perform the action you desire.


Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423


This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  

More information about the Tutor mailing list