#求字符串中长度最长的单词,这是一道贝壳测试开发职位面试题
letters='you are very beautiful'
letter_dic={}
max_length=0
for letter in letters.split(' '):
if letter in letter_dic:
letter_dic[letter]=len(letter)
else:
letter_dic[letter]=1
for k,v in letter_dic.items():
max_length=letter_dic[k]
if letter_dic[k]>=max_length:
max_length=letter_dic[k]
max_length_letter=k
else:
continue
print(max_length_letter,max_length)