How to append list item to the return function

     def tab():
        .......
     return[a,b,c,d]
     [a,b,c,d] = tab()
 

How can I append a list to the defined function. I want to attach Z to the a, b, c and d.
This is the function that I’ve defined but not sure how to append to the returned list.

    reg = ['Z'] 
    df_dict = {} 
    for item in reg:
         df_dict[item].append(a)

>Solution :

Your tab() function return a list and you want to append something to it.

Therefore:

def tab():
    return [1,2,3,4]

(list_ := tab()).append('Z')

print(list_)

Output:

[1, 2, 3, 4, 'Z']

Leave a Reply