Demonstrates nested sequences : Nested List : List PYTHON examples


PYTHON examples » List » Nested List »

 

Demonstrates nested sequences


Demonstrates nested sequences

scores = []

# add score
name = raw_input("What is the player's name?: ")
score = int(raw_input("What score did the player get?: "))
entry = (score, name)
scores.append(entry)
scores.sort()
scores.reverse()        # want the highest number first
scores = scores[:5]     # keep only top scores

# display
print "High Scoresn"
print "NAMEtSCORE" 
for entry in scores:
    score, name = entry    
    print name, "t", score


           
       



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON examples

 Navioo List
» Nested List