Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6976639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:31:23+00:00 2026-05-27T17:31:23+00:00

while print(‘Type ROLL to roll for your stats.’): roll = input() # I get

  • 0
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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T17:31:23+00:00Added an answer on May 27, 2026 at 5:31 pm

    A few things here and there:

    • Your while loop won’t work, since the return value of print is None. It won’t execute, which I don’t think is what was intended. You can change that to an indefinite loop by while True or while 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 to roll = input('Type ROLL to roll for your stats.)

    • Neither no nor NO are 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 as if 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).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

while(1){ //Command prompt char *command; printf(%s>,current_working_directory); scanf(%s,command);<--seg faults after input has been received. printf(\ncommand:%s\n,command);
To my surprise in the following program the Eclipse console doesn't print while in
Given the following code (that doesn't work): while True: # Snip: print out current
How to generate a KeyboardInterrupt in Windows? while True: try: print 'running' except KeyboardInterrupt:
How can I print a blank line at some line with one pressing while
In the following program, why does hitting the a key print hello, world while
I have the follwoing script #!/usr/bin/perl open IN, /tmp/file; s/(.*)=/$k{$1}++;$1$k{$1}=/e and print while <IN>;
When I'm trying get method from remote webservice it gives me error. My code
Trying to redirect a subprocess' output to a file. server.py: while 1: print Count
#!/usr/bin/env python import os, sys, subprocess, time while True: print subprocess.call(xsel, shell=True); time.sleep(1); Takes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.