0

This is a piece of code I made which works as expected except for the else branch. I have to type in a response without y 3 times to successfully go into that branch. Does anyone understand why that is happening?

def marker_question(position, marker_position): invalid_input = True while invalid_input: write("Would you like to do anything with the marker?") answer = input().lower().strip() if "y" in answer: write("Would you like to pick it up and place it or would you like to teleport to it?") answer = input().lower().strip() if "pick" in answer or "place" in answer: marker_position = position invalid_input = False elif "teleport" in answer: position = marker_position invalid_input = False else: write("That is not a possible action") else: write("You have decided to do nothing with the marker") invalid_input = False return position, marker_position 

Here is an example image of input/output Test

7
  • What, if anything, is the code printing out when you do this? A transcript of a run exhibiting the problem would be helpful. Commented Sep 5, 2018 at 3:12
  • Can you show the output/input of your program where you say you have to do it 3 times? To me it only seems like there would be a case where you would have to type something without y 2 times. Commented Sep 5, 2018 at 3:12
  • There are two else branches in this code. Which are you referring to? Commented Sep 5, 2018 at 3:48
  • What is write()? Commented Sep 5, 2018 at 3:48
  • so to answer John Gordon write is a self defined print function which prints every character in the arguement with the tiniest time.sleep() in between which prints out things very aesthetically. Also I am referring to the last else statement. To answer everyone else I will edit the question to have an example Commented Sep 5, 2018 at 5:05

1 Answer 1

1

I'm not sure what the issue but try input with quotation marks It's work for me enter image description here

Check the input function if you use it right

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

1 Comment

strangely enough that works. Ill just make it so it adds that to the outsides of the input.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.