0% found this document useful (0 votes)
9 views6 pages

examples without output

python simple examples

Uploaded by

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

examples without output

python simple examples

Uploaded by

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

String manipulation methods

Examples

txt = "python is FUN!"

x = txt.capitalize()
print (x)

x = txt. title()
print (x)
x = txt.find(“n”)
print (x)
x = txt.rfind(“n”)
print (x)

x = txt.upper()
print (x)
x = txt.lower()
print (x)
x = txt.casefold()
print (x)

x = txt.swapcase()
print (x)
x = txt.partition(“n”)
print (x)

x = txt.rpartition(“n”)
print (x)
x = txt.replace(“n”)
print (x)

x = txt.index(“p”)
print (x)
x = txt.rindex(“F”)
print (x)
x = txt.rjust()
print (x)
x = txt.ljust(“n”)
print (x)

x = txt. center()
print(X)
x = “*”.join(txt)
print (x)
x = txt. strip()
print (x)
x = txt. lstrip()
print (x)
x = txt. rstrip()

print(x)
x = txt.zfill(20)
print (x)

txt=”python is fan”

tran=str.maketrans(“a”,”u”)

x = txt.translate(tran)

print (x)

x = txt.maketrans(“a”,”u”)

print (x)

fruits=”apple, banana, mango”


x = fruits. split()
print(X)
fruits=”apple, banana, mango”
x = fruits. rsplit()
print(X)

txt=”hello every one\nwelcome”

x = txt. splitlines()
print(X)

txt=”python is fun”

txt = "H\te\tl\tl\to"

print(txt)

print(txt.expandtabs())

print(txt.expandtabs(2))

print(txt.expandtabs(4))

print(txt.expandtabs(10))

txt=”python is fun”

x=txt.isprintable()

print(x)

x=txt.isspace()

print(x)

x=txt.isprintable()

print(x)

x=txt.isprintable()

print(x)

x=txt.isalnum()

print(x)

x=txt.isascii()
print(x)

x=txt.isnumeric()

print(x)

x=txt.isdigit()

print(x)

x=txt.isupper()

print(x)

x=txt.islower()

print(x)

x=txt.endswith()

print(x)

x=txt.startswith()

print(x)

x=txt.isdecimal()

print(x)

x=txt.isprintable()

print(x)

You might also like