Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4e48df1

Browse files
Update practice.py
1 parent fe32895 commit 4e48df1

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

‎bits_wilp/practice.py‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,17 @@ def most_common(str_a, str_b):
33

44
result = most_common("NAINA", "RENNE")
55
print(result) # {N}
6+
7+
def get_freq(str):
8+
freq_dict = {}
9+
for char in str.split():
10+
if char not in freq_dict.keys():
11+
freq_dict[char] = 1
12+
else:
13+
freq_dict[char] += 1
14+
15+
return freq_dict
16+
17+
result = get_freq("Amogh loves to eat apple and mango. His sister also loves eating apple and mango")
18+
print(result)
19+
# {'Amogh': 1, 'loves': 2, 'to': 1, 'eat': 1, 'apple': 2, 'and': 2, 'mango.': 1, 'His': 1, 'sister': 1, 'also': 1, 'eating': 1, 'mango': 1}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /