jeudi 25 avril 2019

How can I make an if-statement based on what has randomly been printed?

so I am creating a type of game that will involve dices. What I plan on doing is to have different things happening depending on what the player throws, it will be a 2 player game.

What I want to do is make the computer randomly generate 2 of the 6 possible dice sides. After that has been printed, the computer will move onto an if-statement where it will see ex: if a dice_1 and a dice_3 has been printed, the computer will do something. If it has printed a 1 and a 1, it will do another thing and so on.

This is what I have so far:

import random
for x in range(2):
  print random.randint(1,7) 

So basically, to repeat what I need is a way to use the if-statement to check if the random numbers are ex: 1 and 3 & another example is to check if the numbers add up to 6.

Thanks.




Aucun commentaire:

Enregistrer un commentaire