Input a string and determine whether it is a palindrome or not; convert the case of characters in a string
# Python Program to check whether string is palindrome or not
str=input("Enter a string:")
w=""
for element in str[::-1]:
w = w+element
if (str==w):
print(str, 'is a Palindrome string')
else:
print(str,' is NOT a Palindrome string')
Output:
Enter a string:"welcome"
('welcome', ' is NOT a Palindrome string')
>>>
Enter a string:"kanak"
('kanak', 'is a Palindrome string')
>>>
# Python Program to convert the case of characters in a string
str=input("Enter a string:")
w=""
for element in str[::1]:
if element.isupper():
w = w+element.lower()
else:
w = w+element.upper()
print(w)
Output:
Enter a string:"Welcome to cbsepython.in. BEST website to CBSE Computer Science" wELCOME TO CBSEPYTHON.IN. best WEBSITE TO cbse cOMPUTER sCIENCE >>>