NP71. 喜欢的颜色
描述
输入描述
无输出描述
Python 解法, 执行用时: 9ms, 内存消耗: 2840KB, 提交时间: 2022-06-17
z={ 'Allen':['red','blue','yellow'], 'Tom':['green','white','blue'], 'Andy':['black','pink']} for i in sorted(z): print("%s's favorite colors are:" %i) for a in z[i]: print(a)
Python 解法, 执行用时: 9ms, 内存消耗: 2944KB, 提交时间: 2022-06-04
result_dict = { 'Allen': ['red', 'blue', 'yellow'], 'Tom': ['green', 'white', 'blue'], 'Andy': ['black', 'pink'] } for i in sorted(result_dict): print("%s's favorite colors are:" % i) for j in result_dict[i]: print(j)
Python 解法, 执行用时: 10ms, 内存消耗: 2832KB, 提交时间: 2022-07-19
result_dict = {'Allen': ['red', 'blue', 'yellow'],'Tom': ['green', 'white', 'blue'],'Andy': ['black', 'pink']} for m,n in sorted(result_dict.items()): print("{}'s favorite colors are:".format(m)) for x in n: print(x)
Python 解法, 执行用时: 10ms, 内存消耗: 2832KB, 提交时间: 2022-07-19
result_dict = {'Allen': ['red', 'blue', 'yellow'],'Tom': ['green', 'white', 'blue'],'Andy': ['black', 'pink']} for i in sorted(result_dict): print(i+"'s favorite colors are:") print(result_dict[i][0]) print(result_dict[i][1]) try:print(result_dict[i][2]) except:continue
Python 解法, 执行用时: 10ms, 内存消耗: 2836KB, 提交时间: 2022-06-24
result_dict={'Allen': ['red', 'blue', 'yellow'], 'Tom': ['green', 'white', 'blue'], 'Andy': ['black', 'pink']} for key,value in sorted(result_dict.items()): print("{}'s favorite colors are:".format(key)) for j in result_dict[key]: print(j)