2017-06-25 18 views
-1

私はノートブックの2D配列を作成しようとしていますが、プログラムを実行しようとしたときに、をarray.append([ask](note))にハイライト表示する構文エラーが発生しました。 これを手助けしてください。ありがとう!Python array.appendエラー、どうすれば修正できますか?

for i in range (0,9): 
array = [["Section 0",],["Section 1",],["Section 2",],["Section 3",],["Section 4",],["Section 5",],["Section 6",],["Section 7",],["Section 8",],["Section 9",]] 
print(array) 
ask = int(input("What section of the book do you want to change or add the note? 0-9 :")) 
if ask <= 9: 
    print("Can you not read?") 
    input() 
else: 
    note = str(input("What note do you want in your chosen section? : ") 
    array.append([ask](note)) 
    print(array) 

input() 
+2

あなたは前の行に近い括弧を忘れています。 –

答えて

2

正しい構文はarray[ask].append(note)です。

また、有効なセクション番号を入力してもユーザーを侮辱します。

for i in range (0, 9): 
    array = [["Section 0",],["Section 1",],["Section 2",],["Section 3",],["Section 4",],["Section 5",],["Section 6",],["Section 7",],["Section 8",],["Section 9",]] 
    print(array) 
    ask = int(input("What section of the book do you want to change or add the note? 0-9 :")) 
    if not 0 <= ask <= 9: 
     print("Can you not read?") 
     input() 
    else: 
     note = str(input("What note do you want in your chosen section? : ")) 
     array[ask].append(note) 
     print(array) 
関連する問題