What is the output of the following code?fruit = - ProProfs Discuss
Cancel
TopicsDown
Products Down
Follow Us:
FacebookTwitter
Advertisement

What is the output of the following code?fruit = 'banana'fruit[ = 'B'print fruit



A. Banana
B. Traceback (most recent call last):File \\, line 2, in IndexError: string index out of range
C. Traceback (most recent call last):File \\, line 2, in TypeError: str object does not support item assignment
D. B
E. None of the above

This question is part of Comp150 Python Exam 2009
Asked by Zilch, Last updated: Sep 09, 2020

+ Answer
Request
Question menu
Vote up Vote down

1 Answer

zilch

zilch

zilch
Zilch

Answered Nov 09, 2017

Traceback (most recent call last): File "", line 2, in TypeError: str object does not support item assignment

>>> Traceback (most recent call last): File /Users/imac/OneDrive/OneDriveBusiness/COMP150/Previous Exams/Untitled.py, line 2, in fruit[0] = B TypeError: str object does not support item assignment >>>
upvote downvote
Reply 

Advertisement
Advertisement
Search for Google images Google Image Icon
Select a recommended image
Upload from your computer Loader
Image Preview
Search for Google images Google Image Icon
Select a recommended image
Upload from your computer Loader
Image Preview
Search for Google images Google Image Icon
Select a recommended image
Upload from your computer Loader

Email Sent
We have sent an email to your address "" with instructions to reset your password.