我试图找到两个数字(totMax和totMin)的最大值,每个数字都有对应的列表(totMaxList和totMinList)。我需要将与该编号对应的列表存储在变量“最高”中,假设两个数字都在20以下。如果只有一个数字满足条件,则将存储与该编号对应的列表。存储在totMax中的数字始终高于存储在totMin中的数字。有更简洁的方法吗?
if totMax > 20 and totMin > 20:
raise ValueError(f"Both out of range")
elif totMax <= 20:
highest = totMaxList
elif totMin <= 20:
highest = totMinList
return highest
Why not use a
max()
command: