i have 2 arrays, one is the main array, other is temp, that temp array chooses 1 random number and then its supposed to remove that member in the main array, since the content of both arrays is identical . how to do that ? down is the code
import random
spil=['1t','2t','3t','4t','5t','6t','7t','8t','9t','10t','12t','13t','14t'\
,'1k','2k','3k','4k','5k','6k','7k','8k','9k','10k','12k','13k','14k'\
,'1e','2e','3e','4e','5e','6e','7e','8e','9e','10e','12e','13e','14e'\
'1p','2p','3p','4p','5p','6p','7p','8p','9p','10p','12p','13p','14p']
print(spil)
izvucena = random.sample(['1t','2t','3t','4t','5t','6t','7t','8t','9t','10t','12t','13t','14t'\
,'1k','2k','3k','4k','5k','6k','7k','8k','9k','10k','12k','13k','14k'\
,'1e','2e','3e','4e','5e','6e','7e','8e','9e','10e','12e','13e','14e'\
'1p','2p','3p','4p','5p','6p','7p','8p','9p','10p','12p','13p','14p'],1)
spil.remove(izvucena)
print(spil)
Your problem is that
random.samplereturns a list, you really want to do something like this:Although it’d be simpler to use
random.choiceinstead: