Python Dictonary或带字符串的List |具有排序的Int数据结构

时间:2017-08-09 22:09:32

标签: python python-2.7

我需要某种方式来附加键和键。数据到列表然后操纵该数据。然后我需要对列表进行降序排序,并能够打印出键和值。

list = []
goal scored by team:
 (check key England isn't in list)
  list.append("England", 0)
 else
  list["England"] = list["England"] + 1

 (check key England isn't in list)
  list.append("Scotland", 0)
 else
  list["Scotland"] = list["Scotland"] + 1

sortdescend(list)

print(list[0])
> "Germany", 25
print(list[1])
> "England", 10
print(list[2])
> "France", 8

0 个答案:

没有答案