问题在于,当我到达“ 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)
答案 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瓶啤酒。”
您必须在此行之前更新复数!