我得到奇怪的输出,如100公斤=103公斤,而磅到公斤的转换工作得非常好,
def calculate_1rm(weight_unit, squat, deadlift, bench_press, reps):
try:
squat, deadlift, bench_press, reps = float(squat), float(deadlift), float(bench_press), int(reps)
except ValueError:
return "Invalid input, please enter a number for all lifts"
if weight_unit.lower() == "kg":
squat = kg_to_lbs(squat)
deadlift = kg_to_lbs(deadlift)
bench_press = kg_to_lbs(bench_press)
weight_unit = "lbs"
if weight_unit.lower() == "lbs":
squat = lbs_to_kg(squat)
deadlift = lbs_to_kg(deadlift)
bench_press = lbs_to_kg(bench_press)
weight_unit = "kg"
在这些转换之后,我根本没有触及这些值
我试过除以/.453592(相同的结果),并尝试将变量(深蹲,硬拉,卧推)乘以2.205,但没有运气
1条答案
按热度按时间pxq42qpu1#
将第二个'if'语句替换为'elif'。修改的代码: