Python题目:1、循环打印列表中每个元素,遇到列表则再循环打印出它里面的元素, li = [11, (1, 2), 4, "admin", [3, 7, 8, "shanshan"], 5, "tester001"]
时间: 2023-06-06 18:07:16 浏览: 83
答案:
11
(1, 2)
4
admin
3
7
8
shanshan
5
tester001
代码如下:
li = [11, (1, 2), 4, "admin", [3, 7, 8, "shanshan"], 5, "tester001"]
for item in li:
if type(item) == list:
for sub_item in item:
print(sub_item)
else:
print(item)
阅读全文