Skip to main content

Program To Perform Various Operatios Of String in Python

· One min read
Kaustubh Kulkarni
file.py
# Write a program to perform various operatios of string
str1=str(input("Enter String : "))
# Length of string
print(len(str1))
# checking if substring present or not
print("abc " in str1)
# reversing string
print(str1[::-1])
# trimming string
print(str1.strip())
# Encoding String
print(str1.encode())
#Lowercase
print(str1.lower())
# Uppercase
print(str1.upper())
file.py
Output:
Enter String : Kaustubh K..com Blogs
Kaustubh K..com Blogs
18
False
Kaustubh K..com Blogs
b'Kaustubh K..com Blogs'
Kaustubh K..com blogs
Kaustubh K..COM BLOGS