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
>>>

 

 

By Jitendra Singh

A complete solution for the students of class 9 to 12 having subject Information Technology (402), Computer Science (083). Explore our website for all the useful content as Topic wise notes, Solved QNA, MCQs, Projects and Quiz related to the latest syllabus.

Copywrite © 2020-2025, CBSE Python,
All Rights Reserved
error: Content is protected !!