Write a python program to enter a string and find out the number of Upper and Lower case Characters

Tech Programmer
0

WRITE A PYTHON PROGRAM TO ENTER A STRING AND FIND OUT THE NUMBER OF UPPER AND LOWER CASE CHARACTERS.


CODE FOR THE ABOVE  PYTHON  PROGRAM :



def stringcount(s):
    d = {"UPPER_CASE":0,"LOWER_CASE":0}
    for c in s:
        if c.isupper():
            d["UPPER_CASE"]+=1
        elif c.islower():
            d["LOWER_CASE"]+=1
        else:
            pass
    print(" THE ORIGINAL STRING IS : ",s)
    print(" THE NO OF UPPER CASE CHARACTERS ARE : ",d["UPPER_CASE"])
    print(" THE NO OF LOWER CASE CHARACTERS ARE : ",d["LOWER_CASE"])

stringcount(" COMPUTER SCIENCE WITH PYTHON")


WRITTEN CODE FOR THE ABOVE PROGRAM :


def stringcount(s):

    d = {"UPPER_CASE":0,"LOWER_CASE":0}

    for c in s:

        if c.isupper():

            d["UPPER_CASE"]+=1

        elif c.islower():

            d["LOWER_CASE"]+=1

        else:

            pass

    print(" THE ORIGINAL STRING IS : ",s)

    print(" THE NO OF UPPER CASE CHARACTERS ARE : ",d["UPPER_CASE"])

    print(" THE NO OF LOWER CASE CHARACTERS ARE : ",d["LOWER_CASE"])

 

stringcount(" COMPUTER SCIENCE WITH PYTHON")


OUTPUT :




Post a Comment

0Comments
Post a Comment (0)

Featured Highlighted Categories

You'll discover all of the most up-to-date bring innovative here.

Python List theory with List Programs
Get complete python lists theory and list basic and insane programs for your practice.
CBSE SAMPLE PAPERS
Get CBSE sample and question papers of last 7 years with answers to get best practice for your Board Exams
Python String theory and String Programs
Python strings complete theory with illustrations and practice programs for free