absolute beginner here and it's driving me insane already. Basically, the following is a back and forth game with the PC - if you both pick steal you both loose, if you pick deal and PC picks steal you lose so on and so forth. I have got the code to a point where it can out put the results base on what I put in and what the PC randomly selects however I cannot get the if statement to detect the results and work out if you win or lose.
selection = 'Steal Deal or Quit'
human = input('Steal, Deal or Quit [s|d|q]?:')
print(" ")
if human == 'steal':
print('You chose: ' + selection.split(" ")[0])
if human == 's':
print('You chose: ' + selection.split(" ")[0])
if human == 'deal':
print('You chose: ' + selection.split(" ")[1])
if human == 'd':
print('You chose: ' + selection.split(" ")[1])
if human == 'quit':
print('You chose: ' + selection.split(" ")[3])
if human == 'q':
print('You chose: ' + selection.split(" ")[3])
#Computer input
sd = ["Steal", "Deal"]
computer = print('Comp chose: ' + random.choice(sd))
if human == sd:
print('Draw!')
Aucun commentaire:
Enregistrer un commentaire