Skip to content

Commit 836afb1

Browse files
Mapping keys and values in dict
1 parent 5931647 commit 836afb1

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

other_dsa/mapping_keys_values.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
arr = ["viv", "takleya", "viv", "somi", "somi", "takleya", "lulu"]
2+
3+
obj={}
4+
for i in range(len(arr)):
5+
if(arr[i] in obj):
6+
obj[arr[i]] = obj[arr[i]] + 1
7+
else:
8+
obj[arr[i]] = 1
9+
print(obj)

0 commit comments

Comments
 (0)