Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
*args and Tuples
#5
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:
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.
Reply


Messages In This Thread
*args and Tuples - by millpond - Aug-22-2019, 04:22 AM
RE: *args and Tuples - by Gribouillis - Aug-22-2019, 05:04 AM
RE: *args and Tuples - by millpond - Aug-22-2019, 07:44 AM
RE: *args and Tuples - by Gribouillis - Aug-22-2019, 07:59 AM
RE: *args and Tuples - by joe_momma - Dec-15-2019, 05:54 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020