"Python strings are immutable" Explain in details what is that mean. Provide examples of strings in Python and how it can be used
Strings are immutable means once we create the string we can't change the data in the string that is called immutable.
t= "Hello"
print(t)
#here you will get an error
#because we can't chagne the data of string object
t[0] = "M"
In Python Strings are sequence of characters. we use strings with ""
h = "Hello World" #here we have created a string
print(h) #here we are printing the string
print(h[0]) # here we are printing the first char in the string
h="Hello World"
print(h) #prints complete string
print(h[0]) #prints 1st char
print(h[2:5]) #prints between 2 to 5
NOTE : PLEASE COMMENT BELOW IF YOU HAVE CONCERNS.
Please Like and Support me as it helps me a lot
Get Answers For Free
Most questions answered within 1 hours.