Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

string upper lower count python

# count uppercase,lowercase,digits and special characters.
a=input('enter the string:')
u=l=d=s=0
for i in a :
    if i.isupper():
        u+=1
    elif i.islower():
        l+=1
    elif i.isdigit():
        d+=1
    else:
        s+=1
print('if the string is upper',u)
print('if the string is lower',l)
print('if the string is digit',d)
print('if the string is special',s)

#output:
'''
enter the string: 'Hii Buddy! How Have You BEEN , Welcome To PYTHON....
if the string is upper 17
if the string is lower 20
if the string is digit 0
if the string is special 17
'''

 
PREVIOUS NEXT
Tagged: #string #upper #count #python
ADD COMMENT
Topic
Name
3+2 =