JO KEN PO’s game gone wrong

Asked

Viewed 138 times

0

I’m trying to make a game of jokenpo but it’s gone wrong.

from random import choice
from time import sleep
print('[1]PAPEL\n'
      '[2]TESOURA\n'
      '[3]PEDRA')
escolha = input('Qual a sua escolha? ')
print('JO')
sleep(1)
print('KEN')
sleep(1)
print('PÔ')
lista = [1,2,3] #1(PAPEL),2(TESOURA),3(PEDRA)
pc_escolha = choice(lista)
if escolha == 1 and pc_escolha == 3 or escolha == 3 and pc_escolha == 2 or escolha == 2 and pc_escolha == 1:
    print('-*'*20)
    print('VOCÊ JOGOU {} E O COMPUTADOR JOGOU {}\n'
          'VOCE VENCEU'.format(escolha,pc_escolha))
    print('-*'*20)
elif escolha == pc_escolha:
    print('-*' * 20)
    print('VOCÊ JOGOU {} E O COMPUTADOR JOGOU {}\n'
          'EMPATE'.format(escolha, pc_escolha))
    print('-*' * 20)
elif pc_escolha == 1 and escolha == 3 or pc_escolha == 3 and escolha == 2 or pc_escolha == 2 and escolha == 1:
    print('-*' * 20)
    print('VOCÊ JOGOU {} E O COMPUTADOR JOGOU {}\n'
          'O COMPUTADOR VENCEU'.format(escolha, pc_escolha))
    print('-*' * 20)

  • What is going wrong? In which line is the problem? what should I do and what does?

  • vc should use ( ) to separate the conditions from if where they relate to each other, (a and b) or ( b and c) or (c and d)

  • Simply does not appear output. It was to appear the contents contained within the repetition structures.

  • @Eltonnunes, it didn’t work

  • 2

    ok, I looked over quickly, you’re comparing integer in if, but input returna str, vc Dve do int(input())

  • Exactly what Elton said, I deleted my answer because I had not seen that the friend had already answered in the comments.

  • I didn’t realize this silly mistake. These mistakes are the worst because the system doesn’t warn you. I thank you.

Show 2 more comments

1 answer

-1


Analyzing your code I found a simple and quick solution.

The entity you choose is receiving a string, I suggest adding an entire type cast to perform the conversion. choice = int (choice)

#conversão de valores em cast

outworking:

teste do codigo

Browser other questions tagged

You are not signed in. Login or sign up in order to post.