while print('Type ROLL to roll for your stats.'):
roll = input() # I get my error right after I input
if roll == "roll" or roll == "ROLL":
strength = random.randint(1, 100)
defense = random.randint(1, 100)
attack = random.randint(1, 100)
print('Your attack level is ' + attack + '.')
print('Your strength level is ' + strength + '.')
print('Your defense level is ' + defense + '.')
print('Would you like to reroll?')
reroll = input()
if reroll == no or reroll == NO:
break
My error is
Traceback (most recent call last):
roll
NameError: name 'roll' is not defined
A few things here and there:
Your while loop won’t work, since the return value of
printisNone. It won’t execute, which I don’t think is what was intended. You can change that to an indefinite loop bywhile Trueorwhile 1. Your code will, in theory, break out of the loop when someone enters ‘no’, but we’ll get to that…You can change your
input()statements to contain the text you want to display in the terminal before they enter a value. For example, you can change one of them toroll = input('Type ROLL to roll for your stats.)Neither
nonorNOare defined as variables. Remember, they need to be strings in order for them to be evaluated, since that is what you are looking for. In the future, it may be advantageous to look into a statement such asif reroll.lower() == 'no', since that will save repeated typing on multiple string entry values.Hopefully these get you on the right track. Don’t forget, if you see an answer you like here, feel free to accept it (so the community knows you’ve got your answer).