<p>一些错误和对代码的建议</p>
<ol>
<li>可以使用<a href="https://docs.python.org/3/library/random.html#random.choice" rel="nofollow noreferrer">random.choice</a>从列表中选择一个随机元素</li>
<li>我认为在<code>exercise1, exercise2...</code>变量中,您的意思是执行<code>[a, b, c, d, e, f]</code>等操作</li>
<li>您可以从<code>w[y][1]</code>中创建一个字符串并打印它以除去最后一个逗号</li>
</ol>
<pre><code>Chest= ["Barbell Bench Press", "Flat Bench Dumbbell Press", "Pushups", "Machine Decline Press", "Seated Machine Chest Press", "Incline Dumbbell Press", "Chest Dips", "Incline Bench Cable Fly", "Incline Dumbell Pull-Over", "Pec-Deck Machine"]
Back= ["Barbell Deadlift", "Bent-Over Barbell Deadlift", "Wide-Grip Pull-Up", "Standing T-Bar Row", "Wide-Grip Seated Cable Row", "Reverse-Grip Smith Machine Row", "Close-Grip Pull-Down", "Single-Arm Dumbbell Row", "Decline Bench Dumbbell Pull-Over", "Single-Arm Smith Machine Row"]
Shoulders= ["Barbell Push Press", "Standing Military Press", "Dumbbell Incline Row", "Seated Overhead Dumbbell Press", "Seated Overhead Barbell Press", "Upright Row", "Arnold Press", "Machine Rear-Delt Fly", "Dumbbell Lateral Raise", "Front Dumbbell Raise"]
Legs= ["Squat", "Leg Curl", "Olympic Lift: Snatch and Power Clean", "Leg Extension", "Bulgarian Split Squat", "Hack Squat", "Dumbbell Lunge", "Leg Press", "Romanian Deadlift", "Machine Squat"]
Biceps= ["Standing Dumbbell Curl", "Hammer Curl", "Incline Dumbbell Curl", "Zottman Curl", "Barbell Bent-over Row", "Chin-up", "Regular EZ Bar Curl", "Underhand Seated Row", "Preacher Curl"]
Triceps= ["Close-grip Bench Press", "Rope Tricep Pushdown", "Tricep Dips", "Overhead Triceps Extension", "Skullcrushers", "Diamond Pushups", "Tricep Kickback", "Dumbbell Press", "Pushups", "One Arm Kettlebell Press"]
Aerobic= ["mile run", "jumping jacks", "sprints", "burpees", "cycling"]
#How I tried to pull randomly from lists
import random
#Choose random exercises from all lists
a = random.choice(Chest)
b = random.choice(Back)
c = random.choice(Shoulders)
d = random.choice(Legs)
e = random.choice(Biceps)
f = random.choice(Triceps)
g = random.choice(Aerobic)
exercise1= [a, b, c, d, e, f]
exercise2= [d, f, e, a, b, c]
exercise3= [c, b, a, d, f, e]
exercise4= [g]
Rest= ["Recovery Day"]
#Workout Routine Organizer
w = [['Monday:',exercise1], ['Tuesday:',Rest], ['Wednesday:',exercise2], ['Thursday:',Rest], ['Friday:',exercise3], ['Saturday:',exercise4], ['Sunday:',Rest]]
y=0
for list in w:
print(w[y][0])
#Join whole list w[y][1] as a string, then print it
print(", ".join(w[y][1]))
print("\n")
y+=1
</code></pre>
<p>输出将是</p>
<pre><code>Monday:
Incline Dumbbell Press, Single-Arm Smith Machine Row, Seated Overhead Barbell Press, Hack Squat, Preacher Curl, Skullcrushers
Tuesday:
Recovery Day
Wednesday:
Hack Squat, Skullcrushers, Preacher Curl, Incline Dumbbell Press, Single-Arm Smith Machine Row, Seated Overhead Barbell Press
Thursday:
Recovery Day
Friday:
Seated Overhead Barbell Press, Single-Arm Smith Machine Row, Incline Dumbbell Press, Hack Squat, Skullcrushers, Preacher Curl
Saturday:
jumping jacks
Sunday:
Recovery Day
</code></pre>