在单词的复数或单数之间进行选择的问题

时间:2019-02-26 16:19:33

标签: python

问题在于,当我到达“ 2瓶啤酒/放下一瓶/传递它”时,下一节是“ 1瓶啤酒在墙上”而不是“ 1瓶”。

def bottles(count):
    for i in reversed(range(count+True)):
        plural = 's' if i-True else ''
        print("{} bottle{} of beer on the wall.\n".format(i, plural))
        print("{} bottle{} of beer.\n".format(i, plural))
        if not i-True: break
        print("Take one down, pass it around.\n")
        print("{} bottle{} of beer on the wall.\n".format(i - 1, plural))

if __name__ == '__main__':       
    bottles(99)

2 个答案:

答案 0 :(得分:1)

您需要使用i > 1,因为当i - 1的{​​{1}}为i == 0时,bool(-1)的条件为真。

答案 1 :(得分:0)

问题出在那一行:

  

FROM base AS final ENV TZ=Europe/Copenhagen RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone WORKDIR /app COPY --from=publish /app .

i = 2 时,您得到:

  

“墙上有1瓶啤酒。”

您必须在此行之前更新复数!

相关问题