jeudi 2 décembre 2021

How to get multiple random values from a specified area in a dictionary

I am trying to create a workout simulator. If the user wants to target two areas, I want to be able to take 3 exercises from each section and then combine them into their own set. How would I take 3 random exercises? I have tried using random.sample with no luck

musclegroup_exercises = {
    'legs': {"squat", "calf raises", "hamstring curls", "deadlifts", "walking lunges"},
    'chest': {"barbell bench", "pushups", "cable fly", "dumbbell fly", "dumbbell incline bench press"},
    'arms': {"bicep curls", "kickbacks", "tricep pushdown", "reverse curls", "hammer curl"},
    'shoulders':{"shoulder press", "lateral raise", "barbell shrug", "bent over reverse flys", "push press"},
    'back':{"dumbbell rows", "back extension", "pull ups", "lat pull downs", "machine seated row"},
    'core':{"sit ups", "crunches", "russian twists", "bicycles", "planks"},
}

print('Here are the possible muscle groups you can target: Legs, Chest, Arms, Shoulders, Back, Core')
print('Here are the possible intensity levels: Easy, Medium, Hard')

num = int(input('Would you like to target one or two muscle groups? '))
if num == 1:
    musclegroup = input('What muscle group would you like to target?  ')
if num == 2: 
    musclegroup1 = input('What is the first musclegroup you would like to target? ')
    musclegroup2 = input('What is the second musclegroup you would like to target? ')    
intensity = input('What intensity level would you like? ')
if intensity == 'Easy':
    rate = '65%'
if intensity == 'Medium':
    rate = '80%'
if intensity == 'Hard':
    rate = '90%'
def createworkout1(y):
    for exercise in musclegroup_exercises[musclegroup.lower()]:
        print(exercise)    
def createworkout2(j,k):
    import random
    half1 = random.sample(musclegroup_exercises[musclegroup1.lower()].items(),3)



Aucun commentaire:

Enregistrer un commentaire