2016-04-11 9 views
-3

文法エラーを言っているコードがあります。文法エラーと言っても何をしているのですか

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

質問デバッグヘルプ(** "なぜこのコードは動作していないのですか?" **)は、質問自体に**必要な動作、*特定の問題またはエラー*、* *を再現するのに必要な最短コード**を含める必要があります。 **明確な問題文**のない質問は他の読者には役に立たない。参照:[最小限で完全で検証可能な例を作成する方法](http://stackoverflow.com/help/mcve) – MattDMo

+0

インタープリタからの正確なエラーメッセージは何ですか? –

+0

'%26'の後に閉じ括弧') 'がありません。構文エラーがある場合は、前の行を調べる必要があります。常に、あなたがSOに投稿するときに、必要な関連情報をすべて人に分かりやすく質問してください。私はそれが不明確でよく書かれていないので、この質問を閉じるために投票しています、それがあったとしても、それは単にタイプミスです。 – tom10

答えて

0

私は閉じ括弧が欠落してラインを参照してください - それが理由かもしれない:

encoded.append((STRINGLIST [I] +キーリスト[i])と26%)を探している

関連する問題