+ 1
Python Challenge explained
Kindly, can someone explain this?? Challenge Question: What is the output of this code? s = "SoloLearn" s[0] = "Y" print(s) Choices: Output is SoloLearn Type Error Syntax Error Output is YoloLearn Quiz returns type error is correct.
2 Respostas
+ 4
OK
firstly, strings in python can be interpreted as immutable lists.
So you can access to any symbol of the given string by its corresponding index number. Remember indexing starts from zero.
Now, keeping in mind that string is immutable list like tuple, we can conclude that trying to change any item of the IMMUTABLE list will lead to error.
to change string we can reassign it or make new one with different variable.
Therefore,
Yes answer is type Error
+ 1
Shadoff You're right. Sorry for the mistake EO4Wellness. I think I should revisit the python course 😅