-1

I am not able to print('player 1 is x'). what am I doing wrong.

def marker():
    mark = ''
    while mark != 'x' and mark != "o":
        mark = input('select x or o:')
    if mark == 'x':
        print("player 1 is x")
vadose
  • 1
  • 1

2 Answers2

0

This works on my end. Are you running this with a Python 3 interpreter?

If you are running it with Python 2.7, input() you will need to put quotes around your string input, due to eval() being called on the input, behind the scenes. Otherwise, it will interpret your input as a name. See here for more.

With Python 2.7:

select x or o:"x"
player 1 is x

With Python 3:

select x or o:x
player 1 is x

Just to cover all bases, you are calling this marker function later, correct?

def marker():
    mark = ''
    while mark != 'x' and mark != "o":
        mark = input('select x or o:')
    if mark == 'x':
        print("player 1 is x")

marker() # <---
0

Is it throwing you any error ?, I ran on my local machine with Python 3.7 interpreter and it works fine after calling the method marker().

  • I was running it on Jupyter-lab and it started working today. I guess it was an error by Jupyter. – vadose Sep 14 '20 at 15:49