Demonstrates nested sequences

2019-06-18 02:17栏目:技术创新
TAG: xpj网址

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 5 scores

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

版权声明:本文由新浦京娱乐站_新浦京娱乐场官网_新浦京娱乐发布于技术创新,转载请注明出处:Demonstrates nested sequences