Comment your answers below! 👇

Python_Dv's tweet image. Comment your answers below! 👇

Diverse perspectives enrich understanding; exploring varied answers is invaluable.


Want to reach a similar performance? 📅 Register to our Webinar 'X Ads for Beginners' to learn how!


Strings cannot be referenced by index, so we will see an error


Answer: C) error › Strings are IMMUTABLE so can't be changed › a[0] = "P" tries to modify a character › TypeError: 'str' object does not support item assignment For beginners: Can READ a[0], but can't WRITE a[0] = "P". To change: a = "P" + a[1:] or a.capitalize()!


~ $ python3.15 >>> a = "python" >>> a[0] = "P" Traceback (most recent call last): File "<python-input-1>", line 1, in <module> a[0] = "P" ~^^^ TypeError: 'str' object does not support item assignment >>>


C) error Because strings in Python are immutable.


Ans. C) error Strings are immutable.


Answer is B. Python. The line of code a[0]="P", changes the value of index 0 in "a" which is "p" to "P". Note the difference, the initial value of index 0 is small letter "p", but with that re-assignment, it will be capital letter "P". Therefore the new "a" becomes "Python".


Strings are immutable, I hear.


ChatGpt: The correct answer is: ✅ C) error Explanation Here’s what the code does step by step: a = "python" a[0] = "P" print(a) a = "python" Creates a string variable a containing "python". a[0] = "P" Attempts to modify the first character of the string. ⚠️ Problem: In…


Start your journey in simulated trading with FTMO, backed by 10 years of experience.


strings are immutable so error


I have learnt something. Strings are immutable...I love python!


d, std python strings don't support item assignments


Lock and load, agents! Your favorite Spike-runners are ready to jump onto your walls. Prep your loadout for the new official VALORANT collection ➤


Strings created in python can’t be modified in place …. C. Error


Error The str is immutable.


Strings are immutable in Python. Can’t perform such an operation. However, this is allowed in many languages.


C) error. Cannot assign "P" to the string a .


C. Line 2 is illegal syntax to access objects of str type.


United States Trends
Loading...

Something went wrong.


Something went wrong.