Words Starting with Upper Case

 Coding Problem Keys 

 Words Starting with Upper Case 

 Problem Statement 

The program must accept a string S containing multiple words as the input. The program must print the words starting with an upper case alphabet in S as the output. If there is no such word, the program must print -1 as the output.

 Input Format 

The first line contains N.
The second line contains N integers separated by a space.

 Output Format 

The first line contains the integer value(s) based on the given conditions.

 Boundary Condition(s) 

3 <= Length of S < 100

 Example Input/Output 1 

 Input 

How are you? I am FINE

 Output 

How I FINE

 Explanation 

The words starting with an upper case alphabets are How, I and FINE.
Hence the output is How I FINE.

 Example Input/Output 2 

 Input 

Cricket Match 1: India vs Pakistan

 Output 

Cricket Match India Pakistan

 Example Input/Output 3 

 Input 

hi dora, is this your map?

 Output 

-1

 Max Execution Time Limit: 500 millisecs 

 Solution 

 Programming Language: Python 3 Language 

l=list(input().strip().split())
f=0
for i in l:
    if(i[0].isupper()):
        print(i,end=" ")
        f=1
if(f==0): print("-1")

# Published By PKJCODERS

 (Note: Incase If the code doesn't Pass the output kindly comment us with your feedback to help us improvise.) 

Comments

Popular Posts

Mango Distribution

Consonants Count in Sliding Window

HCLTech

Ernst & Young

Nielsen

Salesforce