with open("day2\input.txt") as f: data = f.readlines() # Rock Paper Scissors opponent_hand = ["A","B","C"] win_hand = ["B","C","A"] loss_hand = ["C","A","B"] outcome = ["X","Y","Z"] # Loose Draw Win total_sum = 0 for line in data: his_hand = opponent_hand.index(line[0]) if outcome.index(line[2]) == 0: #Loss total_sum += opponent_hand.index(loss_hand[his_hand])+1 if outcome.index(line[2]) == 1: #Draw total_sum += 4 + his_hand if outcome.index(line[2]) == 2: #Loss total_sum += 6 + opponent_hand.index(win_hand[his_hand])+1 print(total_sum)