Python Functions, Packing, and Unpacking Packing and Unpacking Packing

Fradely Dilone
Fradely Dilone
22,790 Points

The result of the tuple is not as in the video on the cli

Code-------- def my_function(*args): for val in args: print(args)

my_function("Hello", "I", "love", "python")

CLI result

python3 functions.py
('Hello', 'I', 'love', 'python')
('Hello', 'I', 'love', 'python')
('Hello', 'I', 'love', 'python')
('Hello', 'I', 'love', 'python')


on the video is

Hello I love python

1 Answer

Jebadeiah Jones
Jebadeiah Jones
10,375 Points

Ah, don't worry this is a really easy thing to miss. You're function loops through each argument in all arguments. You're currently printing all arguments instead of each argument.

I hope that makes sense. I'm trying to stop short of just giving you the answer, because it always seems to click better when I figure it out, but let me know if it's still confusing.