0% found this document useful (0 votes)
5 views1 page

Strings Method in Python

Uploaded by

muhammmad yaseen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views1 page

Strings Method in Python

Uploaded by

muhammmad yaseen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

# strings are immutable

a="!!!!muhammad yaseen!!!!!"
print(len(a))
print(a.upper())
print(a.lower())
print(a.rstrip("!"))
print(a.replace("muhammad yaseen","muhammad junaid"))
print(a.split(" "))
book_heading="introduction to AI"
print(book_heading.capitalize())
print(book_heading.center(50))
print(book_heading.count("i"))
c="importance of education!!!!"
print(c.endswith("!"))
print(c.startswith("I"))
print(c.endswith("nc",0,11))
print(c.endswith("nc"[5:9]))
print(c.find("uc")) #find() is used to search the first occurence of a
given value
#and return the index where it is present.if the given value is absent
from the string then it return to -1
#for example
print(c.find("gsdh")) #it will return index to -1
# print(c.index("regsdfgs")) #index() will give error if the value not
present in the string
str1="welcometomychannel2212\n"
print(str1.isalnum())
print(str1.isalpha())
print(str1.islower())
print(str1.isupper())
print(str1.isprintable())
str2="the wild animals"
print(str2.istitle()) #the title() is used to make every first letter of
each word capital.
# print(str1.startswith("w"))
print(str2.swapcase()) #swapcase() convert upper case to lower case and
vice versa

You might also like