+ 1
How does python pick the highest score?
Lets say somebody played x number of games and the programme should pick the game with the highest points and print it out,how does python do that? A little illustration: G1 = 22 points G2 = 3 points G3 = 56 points G+=1 = …..points Print(”what code should be here?”)
4 Antworten
+ 4
It 100% works
games = [6,5,11,3]
Highestscore = max(games)
print(Highestscore)
+ 5
Check which is greator
highestscore = max(G1,G2,G3)
print(highestscore)
+ 1
Abu Habban What if its a list? Example games = [6,5,11,3]
Highestscore = max(games) wouldnt work.
+ 1
Yes you just need the max() function, built into python. Works on a list or a tuple (or any collection really).