jeudi 12 août 2021

Python - random dices from a list?

So im learning some strings and random module things (im really REALLY noob at this, started last week), and i want to randomly sort 3 dices out of 13 dices, AND say which side of each one of the 3 dices you got.

import random



greendice1 = random.choice("CPCTPC")

greendice2 = random.choice("CPCTPC")

greendice3 = random.choice("CPCTPC")

greendice4 = random.choice("CPCTPC")

greendice5 = random.choice("CPCTPC")

greendice6 = random.choice("CPCTPC")

yellowdice1 = random.choice("CPCTPC")

yellowdice2 = random.choice("CPCTPC")

yellowdice3 = random.choice("CPCTPC")

yellowdice4 = random.choice("CPCTPC")

reddice1 = random.choice("CPCTPC")

reddice2 = random.choice("CPCTPC")

reddice3 = random.choice("CPCTPC")



list1 = list((greendice1, greendice2, greendice3, greendice4, greendice5, greendice6, yellowdice1, yellowdice2, yellowdice3, yellowdice4, reddice1, reddice2, reddice3))

dice1 = random.choice(list1)

dice2 = random.choice(list1)

dice3 = random.choice(list1)



dices = input("Hello, you want to play your dices? (Y/N) ")



if(dices == "Y"):

print('\n'"The result of the first dice is:", dice1)

print("The result of the second dice is:", dice2)

print("The result of the third dice is:", dice3)

else:

print("The End.")

I dont need any really advance tips, i know i should learn myself and i dont want anyone to do it for me, im asking here cuz i cannot find on google cuz I DONT KNOW how to search (like which terms or keywords), as i said, im a really noob.

For now, the code will ask if i want to play the dices, if i type Y, then the code will say the results of my 3 dices (each dice has different chances form those letter CPCTPC etc)

What i really dont know is, how can i make the print at the end type not only the side of the dice that we got, but also WHAT dice, like, we have 6 green dices, 4 yellow dices and 3 red dices.

Anyone got any tip on this?




Aucun commentaire:

Enregistrer un commentaire