Amdocs Coding Questions Solved | Question 3 | Codewindow.in

Question :

In this task you will get an array of strings that contains words you are required to return a map will contain each unique word as a key and the number of occurrences of each word as a value.

Example:
Given the following array of strings:
“hello”, “world”, “this”, “is”, “this”, “hello”
you will return:
“hello”,2
“world”,1
“this”,2
“is”,1

Solution :

Python

#https://codewindow.in
#join our Telegram @codewindow


l1=input().split(',')
s=set(l1)
for i in s:
    if i in l1:
        print(i,l1.count(i))

#end

Follow us

Also Checkout

Leave a Comment

Your email address will not be published. Required fields are marked *