sample = ['AAAA','ABCB','CCCC','DDEF']
Run Code Online (Sandbox Code Playgroud)
我需要消除元素中每个字符与其自身相同的所有元素,例如.AAAAA,CCCCC
output = ['ABCB','DDEF']
sample1 =[]
for i in sample:
for j in i:
if j == j+1: #This needs to be corrected to if all elements in i identical to each other i.e. if all "j's" are the same
sample1.pop(i)
Run Code Online (Sandbox Code Playgroud)
打印样本