>> manyArgs(1) I was called with 1 arguments: (1,) >>> manyArgs(1, 2,..." />

Python: Can a variable number of arguments be passed to a function?

Yes. Def manyArgs(*arg): print "I was called with", len(arg), "arguments:", arg >>> manyArgs(1) I was called with 1 arguments: (1,) >>> manyArgs(1, 2,3) I was called with 3 arguments: (1, 2, 3) As you can see, Python will give you a single tuple with all the arguments.

4 docs.python.org/tutorial/… – Miles May 28 '09 at 8:06 Also important...one may find a time when they have to pass an unknown number of arguments to a function. In a case like this call your "manyArgs" by creating a list called "args" and passing that to manyArgs like this "manyArgs(*args)" – wilbbe01 Feb 16 '11 at 6:02.

Adding to unwinds post: You can send multiple key-value args too. Def myfunc(**kwargs): # kwargs is a dictionary. For k,v in kwargs.iteritems" rel="nofollow">kwargs.iteritems(): print "%s = %s" % (k, v) myfunc(abc=123, def=456) # abc = 123 # def = 456 And you can mix the two: def myfunc2(*args, **kwargs): for a in args: print a for k,v in kwargs.iteritems" rel="nofollow">kwargs.iteritems(): print "%s = %s" % (k, v) myfunc2(1, 2, 3, banan=123) # 1 # 2 # 3 # banan = 123 They must be both declared and called in that order, that is the function signature needs to be *args, **kwargs, and called in that order.

Skurmedel - Here you go. – Aiden Bell Feb 6 '10 at 0:23 @Aiden Bell: lol thanks. – Skurmedel Feb 6 '10 at 0:26.

Not having used Python much, this was my initial idea. Why has this answer been marked down? – CiscoIPPhone May 28 '09 at 8:38 I didn't mark it down, but I would guess it is because it is simply not the answer, and the actual answer is no more complicated than passing an array – David Sykes May 28 '09 at 8:49 4 An array isn't even a basic Python type.(Though you can import such a thing from the standard library.

) If the answer had been 'pass a list' however that would have been less wrong, but still more work than the canonical way given in the accepted answer above. – Kylotan May 29 '09 at 11:27.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions