Python自学:第四章 在for循环结束后执行一些操作
# -*- coding: GBK -*- magicians = ['alice', 'david', 'carolina'] for magician in magicians: print(magician.title() + ", that was a great trick!") print("I can't wait to seee your next trick," + magician.title() + ".\n") print("Thank you, everyone.That was great magic show!")
输出为
Alice, that was a great trick! I can't wait to seee your next trick,Alice. David, that was a great trick! I can't wait to seee your next trick,David. Carolina, that was a great trick! I can't wait to seee your next trick,Carolina. Thank you, everyone.That was great magic show!