Friday, February 1, 2019

Count Me please with spaces

  • Problem Description

    Write a Python program to count the number of lower-case letter, uppercase letters and spaces in the entered string.

    Refer sample input and output for formatting specification.

    All float values are displayed correct to 2 decimal places.

    All text in bold corresponds to input and the rest corresponds to output

    Output:

    First Line: Lowercase count
    Second Line: Uppercase count
    Third Line: Spaces count in the string
  • CODING ARENA
  • s=input()
    count1=0
    count2=0
    count3=0
    for i in s:
        if(i.islower()):
            count1=count1+1
        elif(i.isupper()):
            count2=count2+1
        elif(i.isspace()):
            count3=count3+1
    print(count1)
    print(count2)
    print(count3)
  • Test Case 1

    Input (stdin)
    welcome to elab
    
    
    Expected Output
    13
    
    0
    
    2
  • Test Case 2

    Input (stdin)
    WELCOME TO       Elab
    
    
    Expected Output
    3
    
    10
    
    8

No comments:

Post a Comment