我正在用Python在线做一个瓶子程序作为练习,我已经成功地完成了这个练习,尽管我还停留在最后一步,那就是歌曲的剩余部分的倒计时。你知道吗
例如:如果我输入'4',它只显示:(4个绿色瓶子,挂在墙上4个绿色瓶子挂在墙上 如果一个绿色的瓶子,不小心会掉下来 会有3个绿色的瓶子,挂在墙上)
但我在想办法让它降到3,2,1然后结束。你知道吗
如果我进入“7”,那么它会从7降到1。你知道吗
我被困在哪里,我需要把这个纳入我的计划。你知道吗
def bottles(b)
print(b,"green bottles, hanging on the wall",
b,"green bottles hanging on the wall")
bottleno = int(input("Enter number of bottles: "))
bottles(bottleno)
print("And if one green bottle, should accidentally fall")
print("There'd be", bottleno-1, "green bottles, hanging on the wall")
首先,你的第一行忘了一个
:
。你知道吗您需要做的是在函数中有一个while循环,并将重复的print语句放入其中,如下所示:
相关问题 更多 >
编程相关推荐