String in Python by R4R Team

String is a collection of characters, python provides simple and easy way to manage or manipulate the string. In Python, single character are also a string of length one and string in python are immutable.

String is Immutable :-
It means that at runtime we can not change the index value in the string like
s="mystring"
s[1]='a'

This will give an error

Program-

string1=""
string2="This is my string in python"
print(string1)
print(string2)
s1="Hello"+"world"
print(s1)
s1="Hello"*2
print(s1)
print(s1[0])
print(s1[0:3])
print(len(s1))


Output:-

This is my string in python
Hello world
HelloHello
H
Hel
10

-Here '+' operator in python have a capability to add all type of similar data type like we can add
int +int
float+ float
list+list
string+string
-And '*' is multiple string and number here then it repeat the string as per the number which is multiple.
-Len(string) computes the length of the string.

Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!