String Examples Using Python3

1. Simple Program To Show The Use String Functions using Python3.

str="hello"
str1=str
print(str)
print(str[2])
print(str+"HI")
print(len(str))
print(str.capitalize())
print(str.lower())
print(str.upper())
print(str.isupper())
print(str.islower())
print(str.index("l"))

2. Simple Program To Show The Use String Split() Function using Python3.

str="h:e:l:l:o"
#print(str.split(":"))
a=str.split(":")
for i in a:
    print(i)

3. Simple Program To Show The Use Some More String Functions using Python3.

str="hello"
print(str.startswith("h"))
print(str.endswith("o"))

4. Simple Program To Show The Use Some More String Functions using Python3.

str="hello"
temp=str.join(":").join("helloend")
print(temp)

5. Simple Program To Show The Use Some More String Functions using Python3.

str="hello"
str=str.replace('l','p')
print(str)


6. Simple Program To Show The Use Some More String Functions using Python3.

str="hello hi end of string"
print(str.rindex("l"))
print(str.index("l"))
print(str.find("hi"))
print(str.rfind("l"))


7. Simple Program To Show The Use Some More String Functions using Python3.

s="hello"
print(s)
print(s.upper())
print(s.lower())
print(s.index('l'))
print(s.rindex('l'))
print(s.__len__())
print(s.startswith("h"))
print(s.endswith("o"))

8. Simple Program To Show The Use Some More String Functions using Python3.

s="hello"
print(s.join("hii"))

s="hello world"
print(s.split())