Count Unique Words

Count Unique Words - WIPRO 

Problem:

The program must accept a string S containing multiple words as the input. The program must print the number of unique words (i.e., the words that are not repeated) present in the string S as the output. 

Boundary Condition(s): 

1 <= Length of S <= 1000 

Input Format: 

The first line contains S. 

Output Format: 

The first line contains the number of unique words present in the string S. 

Example Input/Output 1: 

Input: 

I love to code and I like to participate in coding competitions 

Output: 

Explanation: 

The 8 unique words are given below. love code and like participate in coding competitions 

Example Input/Output 2: 

Input: 

Go Back Welcome back 

Output: 

4

Program:

s = input().strip().split()

count = 0 

for i in set(s): 

    if s.count(i) == 1: 

        count += 1 

print(count)        

        

Comments

Popular posts from this blog

Pronic Integers in N - InfyTQ question

Count Strong Points - Accenture

Letters at position of multiples of a number