1 # 判定指定元素在列表中是否存在 2 print('p' in 'python') 3 print('p' not in 'python') 4 5 lst = [10, 20, 'python', 'hello'] 6 print(10 in lst) 7 print(10 not in lst) 8 print(100 in lst) 9 print(100 not in lst) 10 11 #列表元素的遍历 12 for item in lst: 13 print(item)
1 # 判定指定元素在列表中是否存在 2 print('p' in 'python') 3 print('p' not in 'python') 4 5 lst = [10, 20, 'python', 'hello'] 6 print(10 in lst) 7 print(10 not in lst) 8 print(100 in lst) 9 print(100 not in lst) 10 11 #列表元素的遍历 12 for item in lst: 13 print(item)