0

Why c instead of a?

Hi , my problem is that my code encripts the letters z and y with c and d instead a and b This is the code: g=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] k=['h','o','l','y'] f=0 while f<len(k): try: p=g.index(k[f]) u=p+2 k.remove(k[f]) k.insert(f,g[u]) f=f+1 except: c=p-24 print(g[c]) k.insert(f,g[c]) print(k) Any idea of why it happens?

24th Aug 2017, 12:35 AM
colgggh
2 odpowiedzi
0
while f<len(k): try: p=g.index(k[f]) u=p+2 k.remove(k[f]) k.insert(f,g[u]) except: c=p-24 print(g[c]) k.insert(f,g[c]) f += 1 print(k) f = f + 1 should be outsider try except.
24th Aug 2017, 4:41 AM
Paul
Paul - avatar
0
Ahh so that was the problem,thanks for answering!
24th Aug 2017, 8:43 AM
colgggh