Enrollments started for Post Graduate Certificate Program in Applied Data Science & AI By IIT Roorkee | 5 Seats Left
Apply NowLogin using Social Account
     Continue with GoogleLogin using your credentials
Immutable means once a string is created, it can't be edited or modified.
Then, guess what does this print?
a = "cloudx"
a = a + "lab"
print(a)
It prints cloudxlab
as per your guess. But, the original string isn't modified here.
a
is just a pointer to the str
object in the memory which gets assigned a new value when the new string is created. Remember, here a new string is created by concatenating copy of a
and "lab"
and then assigned to a
again. It has no effect on the original string i.e. "cloudx"
(We will study objects later. For now, an object is the same thing as a value)
So, we can't change a character inside the string by using the indexing,
a = "cloudxlab"
a[1] = 'm'
Understand and write this code in the notebook and observe you receive,
a = "cloudxlab"
a[1] = 'm'
Taking you to the next exercise in seconds...
Want to create exercises like this yourself? Click here.
No hints are availble for this assesment
Answer is not availble for this assesment
Note - Having trouble with the assessment engine? Follow the steps listed here
Loading comments...