How to I best pass multiple arguments to and from a function?
sneekula
969
Nearly a Posting Maven
Recommended Answers
Jump to PostHere's one way:
def swap(x,y): a = y b = x return a,b x = 3 y = 5 # prints "This is before the swap: x = 3; y = 5." print "This is before the swap: x = %d; y = %d." % (x,y) x,y …
Jump to PostHere is a case where you don't know exactly how many arguments you will be passing to a Python function:
# explore the argument tuple designated by *args # used for cases where you don't know the number of arguments def sum_average(*args): size = len(args) sum = …
All 8 Replies

Mouche
jrcagle
77
Practically a Master Poster
vegaseat
1,735
DaniWeb's Hypocrite
Team Colleague
Mouche
commented:
always really helpful with python
+1
sneekula
969
Nearly a Posting Maven

Mouche
sneekula
969
Nearly a Posting Maven

Mouche
vegaseat
1,735
DaniWeb's Hypocrite
Team Colleague
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.