class Solution(object):
def findRelativeRanks(self, nums):
"""
:type nums: List[int]
:rtype: List[str]
"""
sort = sorted(nums,reverse=True)
medals = ["Gold Medal", "Silver Medal", "Bronze Medal"]+map(str,range(4,len(nums)+1))
d = dict(zip(sort,medals))
return map(d.get,nums)
dict和zip的用法
>>>zip([1,3],[2,4])
[(1,2),(3,4)]
用zip初始化字典
dict的用法总结:http://blog.csdn.net/guizaijianchic/article/details/71211325
ps:range()返回的是一个list