I think it would be more elegant to use list comprehension here, for example:
my_list=["apple","banana","orange"] my_list=[l.upper() if l == "banana" else l for l in my_list]