# 传统写法: list01 = ["a", "b", "c"] list02 = ["A", "B", "C"] list03 = [] for r in list01: for c in list02: list03.append(r + c) print(list03)
# 列表推导式嵌套 list04 = [r + c for r in list01 for c in list02] print(list04)
# 练习1:
# ["香蕉","苹果","哈密瓜",]
# ["可乐","牛奶",]
# 传统写法: list01 = ["香蕉", "苹果", "哈密瓜", ] list02 = ["可乐", "牛奶", ] list03 = [] for r in list01: for c in list02: list03.append(r + c) print(list03)
# 列表推导式嵌套 list04 = [r + c for r in list01 for c in list02] print(list04)
标签:推导,python,list04,list02,list03,list01,嵌套,print From: https://www.cnblogs.com/Remick/p/17129530.html