On 27 June 2011 19:52, Vincent Balmori <vincentbalm...@yahoo.com> wrote:
> > Last thing I need to do solve is the __str__ problem. I can print the name > fine, but everytime I try to put in the self.hunger and self.boredom values > I get: > > TypeError: Can't convert 'int' object to str implicitly > > OK, so if Python can't convert an int to a str implicitly, then it's up to you to do it *explicitly*, by using the str() conversion function or perhaps by using a format string operation. #For example: a_number = 123 print(a_number) a_number_str = str(a_number) print(a_number_str) a_number_str_nicely_formatted = 'The number value is %4d.' % a_number print(a_number_str_nicely_formatted) Additionally I'd like to point out that your solution is fixed to 3 critters, whilst using a list would allow you to have a variable number of critters and add more if you wanted them while the program was running and without having to go and modify your program to do so. So, I'd suggest that you try to figure out how to eliminate managing your 3 critters via 3 explicit variables and instead store them in a list, and enhancing the program so you can add critters from the menu. (If this is expanding the scope of the excercise beyond what is intended then please ignore my suggestion.) Regards Walter
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor