Code doesn't calculate the score, it is always set on 0
I'm trying to make a code for Paper-Rock-Scissors game and it should read 'rating.txt' file and if there's a record for a person's score start with this score, and if there isn't a record it should start counting from 0. Help me please, here's my code :
import random
person = input('Enter your name:')
print('Hello,', person)
score = []
while True:
user_move = str(input())
user_move = user_move.lower()
to_win = ['rock', 'paper', 'scissors']
computer_choice = random.choice(to_win)
with open('rating.txt') as file:
for line in file.readlines():
line_list = line.split()
if line[0] == person:
score = int(line[1])
if user_move in to_win:
if user_move == computer_choice:
print(f'There is a draw ({user_move})')
score.append(100)
if user_move == 'rock':
if computer_choice == 'paper':
print(f'Sorry, but the computer chose {computer_choice}' )
elif computer_choice == 'scissors':
print(f'Well done. The computer chose {computer_choice} and failed')
score.append(100)
if user_move == 'paper':
if computer_choice == 'scissors':
print(f'Sorry, but the computer chose {computer_choice}')
elif computer_choice == 'rock':
print(f'Well done. The computer chose {computer_choice} and failed')
score.append(100)
if user_move == 'scissors':
if computer_choice == 'rock':
print(f'Sorry, but the computer chose {computer_choice}')
elif computer_choice == 'paper':
print(f'Well done. The computer chose {computer_choice} and failed')
score.append(100)
elif user_move == '!exit':
print('Bye!')
break
elif user_move == '!rating':
print("Your rating:", sum(score))
else:
print('Invalid input')
if line_list[0] == person:
score = int(line_list[1])