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)

    assign[emails[x]] = randomChore
    x = x + 1

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top