Code: Alles auswählen
code=[0, 1, 1, 0, 1, 0]
mydic={1:0,2:0,3:0}
z=0
for t in code:
if code[t]==1 and code[t+1]==0:
z+=1
print("F1",code[t],code[t+1],z)
mydic[z]=mydic[z] + 1 if key in mydic else 1
print(mydic)
z=0
else:
pass
if code[t]==1 and code[t+1]==1:
z+=1
print("F2",code[t],code[t+1],z)
mydic[z]=mydic[z] + 1 if key in mydic else 1
print(mydic)
else:
pass
if code[t]==0 and code[t+1]==1:
z=0
print("F3",code[t],code[t+1],z)
print(mydic)
else:
pass
if code[t]==0 and code[t+1]==0:
z=0
print("F4",code[t],code[t+1],z)
print(mydic)
else:
pass
print(mydic)
Warum zählt er 2 Einser-Ketten, Länge 1, statt eine?