Social Media

1/03/2019

Problems on String

Problem1: Check whether the string entered by the user is palindrome or not.
s=input()
if s==s[len(s)::-1]:
    print("Palindrome")
else:
    print("Not palindrome")

Problem2: Write script to count the number of lower case letters in Python.
s=input()
count=0
for x in s:
    if x.islower():
        count+=1
print("Number of lower case letters are",count)

Problem3: Write an script to count the number of digits in a given string.
s=input()
count=0
for x in s:
    if x.isdigit():
        count+=1
print("Number of digits are",count)

Be First to Post Comment !
Post a Comment