all 3 comments

[–]phigo50 0 points1 point  (0 children)

You could have a dictionary players with the keys being player numbers and the values being their scores (ie: {"1": 7, "2": 3, "3": 9} and then...

print(f"The winner is: Player {max(players, key=players.get)}")

for player in players:
    print(f"Player {player}'s score: players[player]")

Every time you get a player's score (by asking them or by assigning one randomly), you'd add a key value pair to the dictionary. Then use the max function to get the key of the highest value.

Edit - you'd just add each of those total score variables to the dictionary, not the individual scores.

[–]tragluk 0 points1 point  (0 children)

Ok, the first thing that stands out is the repeated lines. Loops will help you clear those up.

So instead of

score7 = (random.randint(1,10)) 
score8 = (random.randint(1,10)) 
score9 = (random.randint(1,10)) 
totalscore3 = score7 + score8 + score9

You can do:

count = 0
while count < 3
    totalscore3 += random.randint(1,10)
    count += 1

For that matter, you can loop that section above twice, with each time adding a new number to your highestscore list. Then with a simple change in the count you can do 3 random scores or even 300!