1

Normally when I do a input for the user, Python waits until they press the enter key. However in my script for some reason Python isn't waiting for an input and keeps printing the text...

user_option(), just has a few print statements in it...

If anyone could tell me how to make it so it will wait until the user enters an input that would be very much appreciated.

Code:

while True:
  user_option()
  decision = input("What coarse of action should I take?")
  decision = decision.strip().lower()
  if decision == "a":
    rehydration()
  elif decision == "b":
    moderate_speed()
  elif decision == "c":
    fast_speed()
  elif decision == "d":
    rest()

I'm running this with Python 3.4.

1
  • 5
    A screenshot of your code is not helpful. Paste your code - as text - into the question. Commented Apr 26, 2015 at 4:09

2 Answers 2

5

Problem is in the input method. In Python 3.x raw_input() does not exits and only input() exits. But in older version input() and raw_input() exits. So according to your Python version use proper method. See more here.

In Python 3.x you can simulate raw_input() by using eval(input())

Sign up to request clarification or add additional context in comments.

1 Comment

What Sawon says is true. Still since William is using 3.4 and input() correctly this couldnt be the answer, can it?
1

In Python, the proper way of grabbing input is

input = raw_input('prompt')

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.