def hits():
while True:
hits = int(input("Number of hits :\t"))
if hits>1000:
print("Invalid integer. Must be from 0 to 1000.")
print()
**elif hit(hits)>at_bats:** #does not know how to fix that
print("Hits cannot be greater than at bats.")
print()
else :
return hits
答案 0 :(得分:1)
为了使代码运行,我们必须修复标记行有2个未绑定名称的事实。
def hits():
while True:
hits = int(input("Number of hits :\t"))
if not 0 <= hits <= 1000:
print("Invalid integer. Must be from 0 to 1000.")
print()
continue
at_bats = int(input("Number of at_bats :\t"))
if hits > at_bats:
print("Invalid integer. At_bats must be greater than hitts.")
print()
else :
return hits
答案 1 :(得分:-1)
我想下面可能是你需要的,虽然我不知道at_bats是什么。
.as-console-wrapper { max-height: 100% !important; top: 0; }