list循环

lists=['张张','丽丽','旺旺','牛奶']
words='namrry,lily,jack,dd'
a=18#int类型没有下标
lists2=['张张','丽丽','旺旺','牛奶',[1,2,3]]
# for name in lists2:#每次从lists里面拿一个值给name
# print(name[2::-1])

#for循环在循环可迭代对象的时候,每次循环的是里面的每一个元素
for name in lists2:
if type(name)==list:#判断一个变量的类型
for i in name:
print(i)
print(name)
原文地址:https://www.cnblogs.com/irisx/p/8640856.html