'''写函数,检查传入字典的每一个value的长度,如果大于2,那么仅保留前两个长度的内容,
并将新内容返回给调用者。'''
def fun1(n):
for i,m in n.items():
m = str(m)
if len(m) > 2:
n[i] = m[0:2]
print(n)
dic = {'name':'fanfan','age':2,'sex':'boy'}
fun1(dic)
# dic = {'name':'fanfan','age':2,'sex':'boy'}
# for i,m in dic.items():
# print(i,'---',m)
# for i in dic.keys():
# print(i)
# for m in dic.values():
# print(m)