我的伯爵有问题吗

2024-09-27 19:16:56 发布

您现在位置:Python中文网/ 问答频道 /正文

我不断得到一个错误的行包含“计数=0”。我不知道为什么,因为这是我试图设置的原始默认值。。你知道吗

max = int(input("enter The number of butterflies that is required: "))
count = 0

while count <= max:
    butterfly=int(input("how many butterflys did u see: "))

    if butterfly >=1:
        count = butterfly+count
    else:
        count=count

    butterfly=input("how many did u see: ")

print("you have reached,",max)

错误行: 缩进错误:未缩进与第5行的任何外部缩进级别不匹配 如果butterfly>;=1:


Tags: ofthenumberinputcount错误maxmany
2条回答

这是一个有效的例子

max = int(input("enter The number of butterflies that is required: "))
count = 0

while count <= max:
    butterfly=int(input("how many butterflys did u see: "))

    if butterfly >=1:
        count += butterfly

    butterfly=input("how many did u see: ")

print("you have reached,",max)

你忘了在第1行加上括号,在第14行加了一个括号

相关问题 更多 >

    热门问题