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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:48:13+00:00 2026-06-09T03:48:13+00:00

Pretty new to python/programming in general, this is my biggest project yet. I am

  • 0

Pretty new to python/programming in general, this is my biggest project yet.

I am writing a program that will do SUVAT equations for you. (SUVAT equations are used to find the displacement, start/end velocity, acceleration and time travelled by an object with constant velocity, you may call them something different.)

I made this list:

variables = ["Displacement", "Start Velocity", "End Velocity", "Acceleration", "Time"]

which is used in the following while/for loop:

a = 0
while a==0:
  for variable in variables:

    # choice1 is what the user is looking to calculate
    choice1 = raw_input("Welcome to Mattin's SVUVAT Simulator! Choose the value you are trying to find. You can pick from " + str(variables))

    # will execute the following code when the for loop reaches an item that matches the raw_input
    if choice1 == variable: 
        print "You chave chosen", choice1
        variables.remove(variable) #Removes the chosen variable from the list, so the new list can be used later on
        a = 1 # Ends the for loop by making the while loop false

    # This part is so that the error message will not show when the raw_input does not match with the 4 items in the list the user has not chosen
    else:
        if choice1 == "Displacement":
            pass
        elif choice1 == "Start Velocity":
            pass
        elif choice1 == "End Velocity":
            pass
        elif choice1 == "Acceleration":
            pass

        # This error message will show if the input did not match any item in the list
        else:
            print "Sorry, I didn't understand that, try again. Make sure your spelling is correct (Case Sensitive), and that you did not inlcude the quotation marks."

Hopefully the comments I have written in the code should explain my intentions, if not, feel free to ask anything.

The problem is that when I run the code, and input choice1, the for loop activates the last line of code:

else:
    print "Sorry, I didn't understand that, try again. Make sure your spelling is correct (Case Sensitive), and that you did not inlcude the quotation marks."

and then prompts me to enter the input again, and will do this as many times as it needs to get to the item on the list that I am typing.

However, I specifically coded that if what I input does not match the item on the list the for loop is currently checking, but does match one of the other items on the list, then it should pass and loop round to checking the next item.

I am probably doing something stupid, but I don’t see it, so please help me figure out what I have to do to get my desired result? I assumed it was the syntax I had wrong so that is why that is the title.

Thanks for any help, I appreciate it.

  • 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-09T03:48:15+00:00Added an answer on June 9, 2026 at 3:48 am

    Besides the problem with the indentation in your pasted code, I would rewrite it as such:

    while True:
        choice = raw_input('...')
    
        if choice in variables:
            print "You chave chosen", choice
    
            # Remove the chosen member from the list
            variables = [v for v in variables if v != choice]
    
            # Break out of loop
            break
    
        # Print error messages etc.
    

    Also remember that string comparisons are case sensitive. I.e 'Displacement' != 'displacement'.

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

Sidebar

Related Questions

I'm pretty new to Python and programming in general, and I was wondering if
I'm writing Python scripts for Blender for a project, but I'm pretty new to
I'm pretty new to Python, and programming in general and I'm creating a virtual
I'm pretty new to Python programming so I have this question: How can I
I'm pretty new to Python programming and would appreciate some help to a problem
I'm pretty new at python and I was wondering if this: def func(self, foo):
I'm fairly new to Python and programming in general. I have done a few
I'm in the process of working on programming project that involves some pretty extensive
I am pretty new to python. I need to create a class that loads
I'm pretty new to Python and, in writing an app, have ended up with

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.