vendredi 31 décembre 2021

Randomly Assign Value

I am working on a program that is supposed to assign a female dancer partner to a male dance partner. The user selects a male dancer and the program should randomly assign a female dancer, and then remove both of the chosen dancers from the original list. In my coding class, I was never taught how to randomly assign like this. Here is the code that I have so far:

import random


maledancers = {"Maciek", "Marek", "Marcel", "Carson", "Brett", "Connor"}
femaledancers = {"Renata", "Karolina", "Maja", "Natalia", "Olivia", "Meghan"}



print("You will be pairing the male dancers with the female dancers.")
print("You will select one of the male dancers and it will get paired with a female dancer randomly")

dancer = input("Out of the male dancers, please select one to be paired: ")

if dancer not in maledancers:
    print("Your choice is not in the list of dancers, please re-enter a dancer from the list")
if dancer in maledancers:
    print("Great we will now randomly give " + dancer + " a partner to dance with")
if dancer.isdigit():
    print("The dancer can't have any numbers in their name. Try again please!")

If anyone has any input as to what I can do here, I'd really appreciate any help. If you answer this question, please show the change in code. Thanks in advance!




Aucun commentaire:

Enregistrer un commentaire