Demonstrates nested sequences,demonstratesnested,scores = []#
Demonstrates nested sequences,demonstratesnested,scores = []#
scores = []# add scorename = 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 firstscores = scores[:5] # keep only top 5 scores# displayprint 'High Scores\n'print 'NAME\tSCORE' for entry in scores: score, name = entry print name, '\t', score
- Test for membership with in,testmembership,inventory =
- Defining Dictionaries: shows an example of a dictionary
- Dictionary for loop,dictionaryforloop,dict = {'x':
- Use tuple as key,usetupleaskey,Matrix = {}M
- Define tuple as key in a dictionary,definetuple,Matrix
- Match two string,matchtwostring,seq1 = 'spam
热门文章:
相关内容
- Test for membership with in,testmembership,inventory =
- Defining Dictionaries: shows an example of a dictionary definition.,
- Dictionary for loop,dictionaryforloop,dict = {'x':
- Use tuple as key,usetupleaskey,Matrix = {}M
- Define tuple as key in a dictionary,definetuple,Matrix = {}M
- Match two string,matchtwostring,seq1 = 'spam
- String method: to lower case,methodlower,quote = 'Pyt
- Finding a substring in a string,findingsubstring,string2 = 'O
- Demonstrates the use of quotes in strings,demonstratesquotes,print
- An index that is too large is replaced by the string size,largerepl
评论关闭