I would like to create a program where 4 out of a group of a specified number will be chosen and another 2 out of another specified number will be chosen as well. For example: ( 55, 50,45, 30, 3, 12, 36, 9,8,13) out of this set, there will be 4 numbers that will be randomly chosen. and then another set for example (54, 43, 21, 39, 46,20,1,5,11) there will be another 2 numbers that will be randomly chosen that are unique. How can I code that?
I decided to write my implementation in Python. This will output 4 unique values from the first list and two unique values from the second list. I think this is what your code should look like:
import random
list1 = [55, 50,45, 30, 3, 12, 36, 9,8,13]
list2 = [54, 43, 21, 39, 46,20,1,5,11]
picked1 = random.sample(list1, 4)
picked2 = random.sample(list2, 2)
print("First Pick:")
for i in picked1:
print(i)
print("Second Pick:")
for j in picked2:
print(j)
Hope this helps!