Computer Science, asked by 1805620, 1 day ago

QUESTION
The version of Python being used is 2.7.
To create a profile on a social media account
"ThePastBook", the user needs to enter a string
value in the form of username. The username
should consist of only characters tagged a-z. If
the user enters an incorrect string containing
digits the system automatically identifies the
number of digits in the string and removes
them.
Write an algorithm to help the system identify
the count of digits present in the username.
Input
The input consists of a string- userName,
representing the username.
Output
Print an integer representing the total count of
digits present in the username. If no digits are
present output 0.
Example
Input
rah23ul

Answers

Answered by shilpa85475
2

As the profile on social media consists of a username.

The username is a collection of numbers and alphabets.

Explanation:

stre =input("enter the string-->")

   countl = 0

   countn = 0

   counto = 0

   for i in stre:

       if i.isalpha():

           countl += 1

       elif i.isdigit():

           countn += 1

       else:

           counto += 1

   print("The number of letters are --", countl)

   print("The number of numbers are --", countn)

   print("The number of characters are --", counto)

Answered by venkatakarthikreddy1
0

Explanation:

stre =input("enter the string-->")

countl = 0

countn = 0

counto = 0

for i in stre:

if i.isalpha():

countl += 1

elif i.isdigit():

countn += 1

else:

counto += 1

print("The number of letters are --", countl)

print("The number of numbers are --",

countn)

print("The number of characters are --",

counto)

Similar questions