-1

I've my bloc elif with a loop inside that compare 2 strings (letters) but even if i put the right letter it still run the loop.. i've been looking thru the forum, tried many things but it still run the loop i've no idea why.

elif wallet > 0: # if player still wants to play (if wallet is not empty)
            restartp = raw_input('Keep playing [y/n] ? ')

            while restartp != 'y' or restartp != 'n':
                    print '[!] Wrong answer !'
                    restartp = raw_input('Keep playing [y/n] ? ')

            if restartp == 'y':
                    restart = 1

            elif restartp == 'n':
                    restart = 0
                    keep = False
xeimos
  • 11
  • 2
  • no i have seen this post, tried both methods didn't help. I have been trying few things but i always get the same result. – xeimos Mar 16 '15 at 13:51

1 Answers1

0

restartp != 'y' or restartp != 'n' will always be True.

You can use instead:

restartp != 'y' and restartp != 'n'

or alternatively:

while restartp not in ('y', 'n'):
user
  • 5,370
  • 8
  • 47
  • 75