[Python] Why do we get a 'None' item when appending an item to an existing list? [duplicate]

Discussão em 'Python' iniciado por Stack, Junho 22, 2025.

  1. Stack

    Stack Membro Participativo

    Use case:
    I want to append a new item along with all the existing items in a list to the same list.
    Ex:

    list = [ 'a', 'b', 'c']


    Appending 'd', expecting the output as: ['a', 'b', 'c', 'a', 'b', 'c', 'd']

    My code:

    list.append(list.append('d'))


    Current output:

    ['a', 'b', 'c', 'd', None]


    Why am I getting a None item here and how can I print the list as expected?

    Continue reading...

Compartilhe esta Página