Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Object-Oriented Python (retired) Inheritance Instance Methods

Xiaoqian Zhou
Xiaoqian Zhou
6,506 Points

NameError: name '' is not defined

Entered the same code as instructed, able to import character from Character and set player = Character() and is getting asked to input Name:. But then if i enter anything (e.g. Kenneth), it will return this error - "NameError: name 'Kenneth' is not defined". Please help~

Xiaoqian Zhou
Xiaoqian Zhou
6,506 Points

Fixed the issue - my mac is on Python 2.7, and input() can only accept existing values defined before. Used raw_input() instead and is able to get around it. :D

Use python 3.5, you'll have use the shell for 3.5 to run the program.

3 Answers

Joseph Holms
Joseph Holms
5,409 Points

I recommend switching to python 3, as generally most applications now are geared towards 3. I recommend mac ports, it may help with an easy python 3 setup

Xiaoqian Zhou
Xiaoqian Zhou
6,506 Points

Huh guess the new question is how to close a question...

Xiaoqian Zhou
Xiaoqian Zhou
6,506 Points

Also needed to remove weapon_choice in 'sab' - not sure why but (arent they both strings?) but using if elif elif else works well