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 7970901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:30:36+00:00 2026-06-04T07:30:36+00:00

Currently I’m working on an assignment that requires that I create a program in

  • 0

Currently I’m working on an assignment that requires that I create a program in which the user enters a number between 0-4. The program then checks which number the user inputs and outputs a specific string. For example if the user enters 4, the program will output “80 or above: Level 4”

The problem is that the user should also be able to quit the program. I decided to create the program so if the user inputs something that is not blank (while input != “”:) the program will run, but if they decide to hit enter the program will end.

This is the code I’ve come up with so far:

def get_level():
    level = raw_input("Enter a number from 0-4 (Press <Enter> to quit): ")
    return level

def check_mark(level):
    if int(level) == 4:
        print "80 or above: Level 4"
    elif int(level) == 3:
        print "70 - 79: Level 3"
    elif int(level) == 2:
        print "60 - 69: Level 2"
    elif int(level) == 1:
        print "50 - 59: Level 1"
    elif int(level) == 0:
        print "Below 50: Level 0"
    else:
        print "ERROR: out of range"

def output(level):
   while level != "":
        level = raw_input("Enter a number from 0-4 (Press <Enter> to quit): ")
        check_mark(level)
        print

def main():
    user_level = get_level()
    user_mark = check_mark(user_level)
    print
    program_output = output(user_level)

main()

I’m pretty aware that the problem has to do with the fact that raw_input only accepts strings which is what activates the “while level != “”:” statement. I tried working around this by placing int() operators before each level. The problem is that it conflicts with the input if the user enters blank since it checks whether the input is an integer. Something like that anyways.

So I was hoping someone could guide me to finding a way around this. It would be much appreciated!

  • 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-06-04T07:30:38+00:00Added an answer on June 4, 2026 at 7:30 am

    You probably want the next looping code:

    def output(level):
       level = raw_input("Enter a number from 0-4 (Press <Enter> to quit): ")
       while level != "":
            check_mark(level)
            level = raw_input("\nEnter a number from 0-4 (Press <Enter> to quit): ")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I have a class that looks like this: public class MyClass : IMyClass
Currently the HashSet<T> constructor that allows you to define your equality comparison yourself is
Currently I'm prototyping search with Lucene.Net-2.0-004 on a web application. It's working very well,
currently we have a column with only integer values declared as NUMBER. At the
Currently, most of the popular websites, like google, yahoo detect if the user connection
Currently, my MVC 3 app has a dependency on a static class that is
Currently, Enum.Parse supports only the comma as the value separator, so that MemberOne,MemberThree will
Currently I have a web service, which loads up any plugins located within its
Currently I am writing a program for an introductory Java class. I have two
Currently I am working on small application in asp.net mvc. It is a some

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.