Meta interview question

Python coding: count the same letters in a single word

Interview Answers

Anonymous

May 2, 2021

# create a dictionary to save the number of occurence name='Havannah' name_cnt = {} for i in name.lower(): name_cnt[i] = name_cnt.get(i, 0)+1 print(name_cnt)

Anonymous

Dec 27, 2020

name='Havannah' list_name=[] for i in range(len(name)): list_name.append(name[i].lower()) list_n=np.unique(list_name) v=list_n.tolist() for i in range(len(v)): print('Count of ',v[i]) print(name.count(v[i]))