首页 > 解决方案 > 试图使这项工作不知道为什么

问题描述

这是我的代码:

# Get the user's starting weight.
weight = input('What is your starting weight? ')

# Display the weight loss table.
for month in range(1, 7):
    weight = -4
    print('At the end of month', month,
          'your weight will be', weight, 'lbs.')

标签: python

解决方案


我想尝试改变:

    weight = -4

到:

    weight -= 4

还将输入设为字符串,如下所示:

# Get the user's starting weight.
weight = int(input('What is your starting weight? '))

# Display the weight loss table.
for month in range(1, 7):
    weight -= 4
    print('At the end of month', month,
          'your weight will be', weight, 'lbs.')
    

推荐阅读