66023


input関数を使おうとしたら以下のようなエラーになってしまいました。

[code]

    File "<ipython-input-21-dfdd02906783>", line 39
        answer_num = input("解答:")
                 ^
    SyntaxError: invalid syntax
    
[/code]

どのようにしたら解決できますか？

[code]

    # -*- coding: utf-8 -*-
    import re
    import random
    import numpy as np
    source = 'english_words.txt'
    
    with oprn(source,'r',encoding = 'utf-8') as f:
        data = f.read().splitlines() 
        english_words = [l.strip() for i, l in enumerate(data) if ((i%2) == 0)] 
        jp_meanings = [l.strip() for i, l in enumerate(data) if ((i%2) != 0)]   
    
    words_dict = dict(zip(english_words,jp_meanings))   
    
    
    n_questions = 50   
    
    
    
    random_index = np.random.randint(low = 0, high = len(english_words), size = n_questions) 
    for question_num in range(n_questions):  
        question_word = english_words[random_index[question_num]] 
        correct_answer = words_dict[question_word]    
        meanings_copy =jp_meanings.copy()         
        meanings_copy.remove(correct_answer)
        wrong_answers = random.sample(meanings_copy,3)   
    
        answer_options = [correct_answer] + wrong_answers    
    
        random.shuffle(answer_options)    
        correct_index = answer_options.index(correct_answer)
    
        print('問{}. {}\n\n'.format(question_num + 1,question_word))  
        for i in range(4):
            print('{}.{}\n'.format(i + 1, answer_options[i])   
        answer_num = input("解答:") #　←←←←←←←←←←←←←←←←←←←←←ここです
        answer_num = int(answer_num)
        if answer_num = correct_index + 1:
            print('correct!')
        else:
            print('wrong!')
            print('correct answer is '+'correct_answer')
        print('\n\n')
    
[/code]


CC BY-SA 4.0
2020-04-27T06:10:30.600
66022
2020-04-27T07:20:31.263
2020-04-27T07:20:31.263
3060
39563
question
python
input関数でSyntaxErrorになってしまう


>
[code]

>        print('{}.{}\n'.format(i + 1, answer_options[i])  
>  
[/code]

カッコの数があってません


CC BY-SA 4.0
2020-04-27T06:19:20.427
66023
2020-04-27T06:19:20.427
27481
66022
answer