题解 | #遍历字典#
遍历字典
http://www.nowcoder.com/practice/0315639767824323a2cdb9ee3f998314
NP27 遍历字典
思路:
按照要求输入输出即可;
代码如下:
operators_dict = {'<':'less than' , '==':'equal'}
print('Here is the original dict:')
k = operators_dict.keys()
for i in sorted(k):
print('Operator {} means {}.'.format(i,operators_dict[i]))
operators_dict['>'] = 'greater than'
print()
print('The dict was changed to:')
kk = operators_dict.keys()
for i in sorted(kk):
print('Operator {} means {}.'.format(i,operators_dict[i]))