Computer Science, asked by chayanikaniyogi, 7 months ago

wap to accept a string display the no. of lower case characters in a string ,upper case, digits, special characters present in a string
when the string is not given
plzzzz answer fast

Answers

Answered by Equestriadash
5

string = input("Enter a string: ")

clw = 0

for i in string:

 if i.islower():

   clw = clw + 1

cup = 0

for i in string:

 if i.isupper():

   cup = cup + 1

cdg = 0

for i in string:

 if i.isdigit():

   cdg = cdg + 1

cspch = 0

for i in string:

 if i in " /+-%,.!@#$&*'":

   cspch = cspch + 1

print("Upper case characters: ", clw)

print("Lower case characters: ", cup)

print("Digits: ", cdg)

print("Special characters: ", cspch)

  • isupper() is a function to check if a character is in upper case or not.
  • islower() is a function to check if a character is in lower case or not.
  • isdigit() is a function to check if a character is a digit of not.
  • in is a membership operator used for checking if a character is in a string or not.
Attachments:
Similar questions