Dec-15-2019, 05:54 PM
the * args is used to pass a number of arguments. the *items is not the list you created below. tutorial on *args **kwargs
If you want a list passed to your function then just pass a list:
If you want a list passed to your function then just pass a list:
def func(my_list): my_list[3]= 1026 res= [] for i in my_list: res.append(i) return res items=[1,3,7,9,-99,555,88] new_item= func(items) print(new_item)
Output:[1, 3, 7, 1026, -99, 555, 88]
if a list is not passed then it will throw an error.