如何修复以下代码以计算一年 365 天的平均步数? [已关闭]

问题描述 投票:0回答:1

该程序用于计算 365 天内所走步数的平均值。

python syntax-error python-3.7
1个回答
-2
投票
with open('steps.txt', 'r') as myfile:
    for x in range(12):
        total = 0
        for y in range(days[x]):
            steps = int(myfile.readline())
            total += steps
        average = total / days[x]
        print(f"The average steps taken in the month of {month[x]} is {average:.2f}")
© www.soinside.com 2019 - 2024. All rights reserved.