链接: https://pan.baidu.com/s/1pNfyZzH 密码: hnbm
li = [2, 5, [1, 7], '8494', 4.0, 10]
print(li)
i = 0
while i < len(li):
print(i, li[i])
i += 1
i = 0
for x in li:
print(i, x)
i += 1
li1 = list(range(1, 10, 1))
li2 = list(range(11, 20, 1))
print(li1)
print(li2)
i = 0
while i < len(li1):
li1[i] += li2[i]
i += 1
print(li1)
li1 = list(range(1, 10, 1))
i = 0
c = 0
while i < len(li1):
if li1[i] % 3 == 0:
print(li1[i])
c += 1
i += 1
print(c)
print(help(type))
s = "aaaa"
print(type(s))
if type(s) == str:
print("s is a", type(s))
li = list(range(1,5))
print(li)
if type(li) == list:
print("li is a", type(li))
# 多重循環,判斷元素類型是否爲list
li = [1, [2, [3, 4], [5]], 6, [7, 8], 9]
# print 1 2 3 4 5 6 7 8 9
for x in li:
if type(x) == list:
for y in x:
if type(y) == list:
for z in y:
if type(z) == list:
for w in z:
if type(w) == list:
pass
else:
print(w)
else:
print(z)
else:
print(y)
else:
print(x)
print("=====")
# 定義遞歸函數
def unlist(n):
for x in n:
if type(x) == list:
unlist(x)
else:
print(x)
unlist(li)