fork download
  1. import random
  2.  
  3. List1 = ["ABC", "DEF"]
  4. List2 = ["GHI", "JKL"]
  5. List3 = ["MNO", "PQR"]
  6.  
  7. def choose():
  8. Choice1 = random.choice(List1)
  9. Choice2 = random.choice(List2)
  10. Choice3 = random.choice(List3)
  11. List1.remove(Choice1)
  12. List2.remove(Choice2)
  13. List3.remove(Choice3)
  14. print (Choice1)
  15. print (Choice2)
  16. print (Choice3)
  17. choose()
  18.  
  19. choose()
Runtime error #stdin #stdout #stderr 0.02s 37976KB
stdin
Standard input is empty
stdout
ABC
GHI
PQR
DEF
JKL
MNO
stderr
Traceback (most recent call last):
  File "/usr/lib/python3.5/random.py", line 262, in choice
    i = self._randbelow(len(seq))
  File "/usr/lib/python3.5/random.py", line 239, in _randbelow
    r = getrandbits(k)          # 0 <= r < 2**k
ValueError: number of bits must be greater than zero

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./prog.py", line 19, in <module>
  File "./prog.py", line 17, in choose
  File "./prog.py", line 17, in choose
  File "./prog.py", line 8, in choose
  File "/usr/lib/python3.5/random.py", line 264, in choice
    raise IndexError('Cannot choose from an empty sequence')
IndexError: Cannot choose from an empty sequence