这是我的代码:bookings = ['blue,red', 'green,orange', 'yellow, purple']number = 0b = 0c = 1file_test = open('test_1.txt' , 'wt')results_song = []for item in bookings: words = bookings[number].split(',') results_song.append(words[0]) results_song.append(words[1]) number = number + 1results_song_str = '\n'.join(results_song)print(results_song_str)file_test.write(results_song_str)file_test.close()file_test = open('test_1.txt' , 'r')line = file_test.readlines()for item in bookings: line_1 = line[b] line_2 = line[c] answer = input('If first word is then what is the second word') if answer == line_2: print('correct') else: print('wrong') b = b + 2 c = c + 2但是,代码不会识别答案等于line_2。我无法弄清楚为什么会这样。我已经检查过这c是正确的数字,并且line_2与答案相同。但我确实注意到,当我在打印答案时运行代码并且line_2这会返回:redred但我从来没有在这里添加新的线路功能。任何帮助将不胜感激,因为我需要将此代码用于学校作业。
添加回答
举报
0/150
提交
取消