1、在for循环中执行更多的操作
messages = [["liuyan", 20], ["deyu", 2], ["ouyan", 28]]
for message in messages:
print(f"你好,我叫{message[0].title()},今年{message[-1]}岁")
# 输出结果:
# 你好,我叫Liuyan,今年20岁
# 你好,我叫Deyu,今年2岁
# 你好,我叫Ouyan,今年28岁
messages = [["liuyan", 20], ["deyu", 2], ["ouyan", 28]]
for message in messages:
for age in message:
print(f"{age}")
# 输出结果:
# liuyan
# 20
# deyu
# 2
# ouyan
# 28