[Python] Looping through a list and assigning values has no effect [duplicate]

Discussão em 'Python' iniciado por Stack, Agosto 19, 2025.

  1. Stack

    Stack Membro Participativo

    I have a list and want to change its elements

    list = ['apple','potato']


    Now, while this works

    for i in range(list):
    list = list.capitalize()


    this one doesn't and I just don't get why

    for i in list:
    i = i.capitalize()


    I'm new to Python, my only background is C++ so I'm still trying to adapt to Python's style.

    Continue reading...

Compartilhe esta Página