我有一些代码一直在说语法错误,请帮忙。
count = 0
output = []
encoded = []
keylist = []
stringlist = []
alphabet = [ "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" ]
print(" what would you like to do: ")
print("options: ")
print("1 - encode")
print("2 - decode")
print()
while 1==1:
option = int(input("option = " ))
key = input("please enter the key you would like to use: ")
string = input("please enter the string you would like to encode/decode: ")
string = string.replace(' ', '')
keylenth = len(key)
stringlenth = len(string)
overlap = stringlenth % keylenth
leftovers = key[:overlap]
random = stringlenth-overlap
random = stringlenth/keylenth
key = (int(random)*key)+leftovers
for i in string:
number = alphabet.index(i.upper())
stringlist.append(number)
i = 0
if(option == 1):
while count < stringlenth:
encoded.append((stringlist[i]+keylist[i])%26
count += 1
i += 1
for n in encoded:
output.appened(alphabet[n])
string = ''.join(output)
print()
print('output::')
print()
print(string)
print()
print()
答案 0 :(得分:0)
我看到缺少右括号的行 - 可能是原因:
encoded.append((stringlist [i] + keylist [i])%26 )