1 Python 3.3.4 (v3.3.4:7ff62415e426, Feb 10 2014, 18:13:51) [MSC v.1600 64 bit (AMD64)] on win32 2 Type "copyright", "credits" or "license()" for more information. 3 >>> cast=["cleese","palin",&qu…
[1]a=[8,13,11,6,26,19,24]1)请输出列表a中的奇数项2)请输出列表a中的奇数 解:1) a=[8,13,11,6,26,19,24] print a[::2] Result:>>>[8, 11, 26, 24] 2) a = [8,13,11,6,26,19,24] b = [] for item in a: if item%2 !=0: b.append(item) else: continue print b Result:>>>[13, 1…
方法一: 元素两两比较,如果有数据不同,则r的值变为false #!/usr/bin/python a=[22,22,22,22] b = len(a) r=True for i in range(b): if i ==(b-1): break if a[i] == a[i+1]: continue else: r=False print(r) 方法二: 数据去重,如果去重后列表中的元素大于1,则说明数据重复 #!/usr/bin/python a=[22,22,22,222] b=len(se…