python - 试图使这项工作不知道为什么
问题描述
这是我的代码:
# 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.')
解决方案
我想尝试改变:
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.')
推荐阅读
- javascript - 如何在 Javascript 中获得 C# FileContentResult 响应?
- c++ - 当我尝试在 c++ 中的 Visual Studio 中将字符串分配给 istringstream 对象时,为什么会出现错误?
- python - 如何在 python 中通过 udp (DTLS) 套接字实现 http/3 协议?
- vega-lite - 使用 vega-lite 为烛台图着色
- javascript - 在反应中通过 onClick 从 array.map 中检索数据
- google-sheets - 条件格式以突出显示跨多列获取的重复项
- c++ - 关于标准 C++ 多线程的简单问题
- iphone - 使用基本卡时,在 Google 助理(对话流)上上传图片操作不适用于 iPhone XR 或 iPhone 11
- sas - SAS Proc Report 带跳行的带状行
- r - 如何在r中重复数据帧的顺序