#Cant set value of a string

5 messages · Page 1 of 1 (latest)

vernal tiger
#

uin = 'place holder'

psel = input(' 1. for X \n 2. for O \n')

if psel == 1:
uin = 'X'
elif psel == 2:
uin = 'O'

print(uin)

Why i am unable to change string value?

cursive arrow
#

input returns a string

trail kernel
#

Damn kintec, you're too quick

cursive arrow
#

So you are checking if '1' == 1. Probably best to convert your input to an int