combine two lists randomly

in your code, the for key in emails: part needed to be removed. it would choose the random chore then loop through, adding the emails without choosing another random chore.

here is the working code.

import random
chores = ['dishes','bathroom','vacuum','walk dog']
assign = {}
emails = ['a','b','c','d']

x = 0
for i in range(0, len(chores)):
    randomChore = random.choice(chores)
    chores.remove(randomChore)

    assign[emails[x]] = randomChore
    x = x + 1
    
print(assign)

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top