Python Question / Quiz; What is the output of the following Python code, and why? 🤔🚀 Comment your answers below! 👇 #python #programming #developer #programmer #coding #coder #softwaredeveloper #computerscience #webdev #webdeveloper #webdevelopment #pythonprogramming #pythonquiz #ai #ml #machinelearning #datascience
@Python_Dv Strings are immutable in Python — you can’t change a single character by indexing. Trying text[1] = 'i' raises a TypeError.
@Python_Dv AI said correct answer is C Here is why:
@Python_Dv text = "hello": A string variable text is initialized with the value "hello" text[1] = 'i': This line attempts to change the second character (index 1) of the string text to 'i' print(text): This line will not be reached due to the error in the previous line Answer: C) Error
@Python_Dv type error string does not support assignment
@Python_Dv baffled. coding in python since 7 years or so. never seen or used string indexing.🤣
@Python_Dv It depends on what the code actually is shown here.
@Python_Dv 😂😂 Such a easy q C would be the correct and String is immutable
@Python_Dv Looks like a fun challenge! Can't wait to see everyone's answers. Python quizzes always spark great conversations!
@Python_Dv Strings are immutable @codewithharry studied from you! 💪🏻