이 코드는 내부에 코드와 컨텍스트를 게시하기가 어렵습니다.
#이 메뉴를 이용한 승산 게임입니다. 난 ... multiplication_game.txt라는 이름의 파일에의 할당하기 전에 output_file = None
을 정의하는로컬 변수 'output_file'을 참조하기 전에이 코드는 몇 주 전에 작동했지만 이제는 어떻게 작동합니까?
def single_player():
in_file = open('multiplication_game.txt', 'r')
highest_times_selection = int(in_file.readline())
print('\n____now lets see how u do on the times tables____')
correct = 0
missed = 0
times_selection = int(input(
'\nPlease enter a times time table integer to practice: '))
#This simple generates the multiplation questions and checks for right or
#wrong.
for number in range(0,11):
print(times_selection, 'x' , number, '=')
user_answer=int(input('answer: '))
correct_answer = times_selection * number
if user_answer == correct_answer:
correct+=1
else:
missed+=1
#This is where if its a perfect score and a high times table than the
#previous saved score it should be opened and the new score saved in the
#text document.
if missed == 0 and times_selection > highest_times_selection :
output_file = open('multiplication_game.txt', 'w')
name = input('You have the highest Score!!\n enter your name: ')
output_file.write(str(times_selection)+ '\n')
output_file.write(name + '\n')
else:
print('you missed ', missed, 'and got', correct,'correct\n')
output_file.close()
올바른 들여 쓰기가있는 코드를 다시 게시 할 수 있습니까? – Bill