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…
Strings are immutable in Python — you can’t change a single character by indexing. Trying text[1] = 'i' raises a TypeError.
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
AI said correct answer is C Here is why:
baffled. coding in python since 7 years or so. never seen or used string indexing.🤣
😂😂 Such a easy q C would be the correct and String is immutable
Looks like a fun challenge! Can't wait to see everyone's answers. Python quizzes always spark great conversations!
United States Trends
- 1. #SmackDown 17.4K posts
- 2. Caleb Wilson 1,874 posts
- 3. Darryn Peterson 1,632 posts
- 4. Kansas 22.9K posts
- 5. Georgetown 2,978 posts
- 6. Reed Sheppard N/A
- 7. Vesia 5,848 posts
- 8. Tiller 4,067 posts
- 9. Dizzy 12.3K posts
- 10. End of 1st 1,841 posts
- 11. #GCWUnderstand N/A
- 12. #kubball N/A
- 13. UMass Lowell N/A
- 14. Oakland 3,310 posts
- 15. End 1Q N/A
- 16. End of the 1st 1,193 posts
- 17. Bruce Thornton N/A
- 18. Grammy 489K posts
- 19. Zelina 1,159 posts
- 20. Sam Merrill N/A
Something went wrong.
Something went wrong.