将字符串转换为浮点数失败


def main():
x = abc_to_def(input("What time is it? "))
if x >= "7.0" and x <= "8.0":
print("breakfast time")
elif x >= "12.0" and x <= "13.0":
print("lunch time")
elif x >= "18.0" and x <= "19.0":
print("dinner time")
else:
print()
def abc_to_def(p):
hours, minutes = p.split(":")
if float(int(hours)) + int(minutes)/int(60):
return p
if __name__ == "__main__":
main()

当我在终端中运行代码时,一切都是正确的,但是当我运行check50时,它说我的输出是"

#!/usr/local/bin/python3

def main():
y = input("What time is it? ")
x = abc_to_def(y)
if x >= 7.0 and x <= 8.0:
print("breakfast time")
elif x >= 12.0 and x <= 13.0:
print("lunch time")
elif x >= 18.0 and x <= 19.0:
print("dinner time")
else:
print("no food")

def abc_to_def(p):
hours, minutes = p.split(":")
p = float(int(hours)) + int(minutes)/int(60)
return p

if __name__ == "__main__":
main()

相关内容

  • 没有找到相关文章

最新更新