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 trialAmmar Fatihallah
7,417 Pointsname 'roll' is not defined
the terminal is saying that the roll is not defined even though i wrote they same code as the video explained and checked the combat.py fie more than one time and nothing has seemed to happend. this is my code if you want to look at it: https://drive.google.com/drive/folders/0B2LZB_NY3It-amx4OE1yNWREVzA?usp=sharing
I have a screenshot of the output of the program on my drive
Chris Freeman
Treehouse Moderator 68,454 PointsCan you please post the stack trace from the error message?
This will show what the code was doing during the error.
1 Answer
Steven Parker
231,271 PointsYour code is a bit different from the code in the video.
As shown in the video "Dry", the attack routine first places a random number in a variable named "roll". But the same method in your version of combat.py places the random number in a variable named "attack". So when the next statement tries to reference the variable using the name "roll", it does not exist (and is therefore "not defined").
jag
18,266 Pointsjag
18,266 PointsIt's better if you post and host your code in workspaces that way we can easily see and modify if need be.
Since workspaces preview only lives temporarily create a snapshot.