Witam uczę się Pythona od 2 tygodni , postanowiłem zrobić taki koder-dekoder szyfru Vigenere'a https://pl.wikipedia.org/wiki/Szyfr_Vigen%C3%A8re%E2%80%99a
po uruchomieniu pokazuje sie błąd IndexError: list index out of range . a oto program:
tab = []
def calfabet(start): #tworzenie alfabetu
for litera in range(start, 91):
alfabet.append(litera)
for reszta in range(65, start):
alfabet.append(reszta)
def encrypt(wordlit, keylit):
calfabet(wordlit)
tab.append(alfabet[keylit-65])
alfabet.clear()
def decrypt(wordlit, keylit):
calfabet(wordlit)
for test in range(0, 25):
if alfabet[test] == keylit:
tab.append(alfabet[0])
alfabet.clear()
print("Co chcesz zaszyfrowac lub odszyfrowac?")
x = input().upper()
print("podaj slowo klucz:")
y = input().upper()
word = []
key = []
wordi = 0 # numer litery slowa
keyi = 0 #numer litery slowa klucza
for znak in x:
word.append(ord(znak))
for znak in y:
key.append(ord(znak))
print("co chcesz zrobic? \n 1) zaszyfrowac: \n 2) odszyfrowac: ")
wybor =input()
if wybor =="1":
while len(tab) < len(x):
if word[wordi] in range(65, 90):
encrypt(word[wordi], key[keyi])
wordi +=1
keyi +=1
else:
tab.append(word[wordi])
wordi +=1
else:
pass
print(tab)```