Python Forum

Full Version: change only one element of list to upper case
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello

I am totally new to python and today learnt about lists, my question is how do i change the case of a particular element in a list

p=["mozzarella","cinderalla","salmonella"]

I want the list to be modified so cinderalla to be all caps



I tried this but not working

p[1]=p[1].upper()
try again. it is working

>>> p=["mozzarella","cinderalla","salmonella"]
>>> p[1]=p[1].upper()
>>> p
['mozzarella', 'CINDERALLA', 'salmonella']
>>>
Looks fine to me?
Output:
>>> p=["mozzarella","cinderalla","salmonella"] >>> p[1]=p[1].upper() >>> p ['mozzarella', 'CINDERALLA', 'salmonella']
yes, my solution works :) maybe i got confused looking at a different error, thanks everyone for your reply..quick question is how do i clear the screen from the python interpretor, do i have to import anything