import random
selection = random.sample(cards, 3)
Gribouillis
Posting Maven
2,786 posts since Jul 2008
Reputation Points: 1,044
Solved Threads: 691
This one runs
colors = ["blue", "yellow", "red"]
forms = ["triangel", "circle", "square"]
numbers = [1, 2, 3]
grades = [1, 2, 3]
cards = []
for color in colors:
for form in forms:
for number in numbers:
for grade in grades:
cards.append((color, form, number, grade))
import random
kortutfall = random.sample(cards, 6)
print kortutfall
""" my output -->
[('red', 'circle', 1, 2), ('blue', 'triangel', 1, 2), ('yellow', 'square', 3, 3), ('blue', 'square', 1, 1), ('yellow', 'triangel', 3, 2), ('red', 'circle', 1, 3)]
"""
Hint: don't write code that you don't understand.
Gribouillis
Posting Maven
2,786 posts since Jul 2008
Reputation Points: 1,044
Solved Threads: 691