Python conversation

l = [‘abc’, ‘apple’,‘banana’]
def f ():
l[1]= ‘guava’
f()
print(l)

Output:
[‘abc’, ‘guava’, ‘banana’]

Can someone please explain Why ‘gauva’ was updated in place of ‘apple’ specifically , and(but) not replace ‘abc’ or ‘banana’.

1 Like

As per indexing l[1], ‘apple’ replaced with guava.

Index value
0 = ‘abc’
1 = ‘apple’
2 = ‘banana’

1 Like