【问题标题】:Find the cost in but it keeps returning errors找到成本,但它不断返回错误
【发布时间】:2022-06-14 23:37:24
【问题描述】:
my_money = input('How much money do you have? ')
boat_cost = 20 + 5

if my_money < boat_cost:
    print('You can afford the boat hire')
else :
    print('You cannot afford the board hire')

【问题讨论】:

  • 提示 - int(输入.....)。 input() 会给你的字符串 (str) 所以你必须把它转换成整数。
  • 你的logic比较也是错误的。
  • 也许船长只把船租给买不起的人,即对穷人的无私姿态

标签: python function python-requests pycharm python-3.7


【解决方案1】:

试试这段代码sn-p,看看原来的代码问题:

my_money = int( input('How much money do you have? '))
boat_cost = 20 + 5

if my_money >= boat_cost:
    print('You can afford the boat hire')
else :
    print('You cannot afford the board hire')

【讨论】:

    猜你喜欢
    • 2022-11-11
    • 1970-01-01
    • 1970-01-01
    • 2014-07-18
    • 1970-01-01
    • 1970-01-01
    • 2014-10-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多