Using VS2015
Python 3.4
Having some issues with this while
counter. It is slowly driving me insane as I'm sure it 'should' work but isn't updating the counter. I've ran stepping debug and can see the counter resetting to 3 before the while condition line. It is annoying me to say the least.
import random
import getpass
print ('Welcome to Rock, Paper or Sissors\nEnter an option.')
user_obj = getpass.getpass('Rock, Paper or Sissors: ').lower()
ai_obj = input('Rock, Paper or Sissors: ').lower()
rps = ('rock', 'paper', 'sissors')
#ai_rps = ['rock', 'paper', 'sissors']
#ai_obj = random.choice(ai_rps)
counter = 3
def rps_game(user_obj, ai_obj):
print('Player selected %s ' % user_obj)
print('Computer selected %s ' % ai_obj)
condition = user_obj in rps and ai_obj in rps
while condition == True and counter >= 0:
if user_obj == ai_obj:
print('Its a draw!')
elif user_obj == 'rock':
if ai_obj == 'paper':
print('You lose!')
break
else:
print('You win!')
elif user_obj == 'paper':
if ai_obj == 'sissors':
print('You lose!')
break
else:
print('You win!')
elif user_obj == 'sissors':
if ai_obj == 'rock':
print('You lose!')
else:
print('You win!')
break
else:
counter += 1
print('Invalid input, please select Rock, Paper or Sissors')
rps_game(user_obj, ai_obj)
rps_game(user_obj, ai_obj)