test function:

You can use multiple arguments represented by *args and multiple keywords represented by **kwargs and passing to a function:

def test(*args, **kwargs):
    print('arguments are:')
    for i in args:
        print(i)

    print('\nkeywords are:')
    for j in kwargs:
        print(j)

Example:

Then use any type of data as arguments and as many parameters as keywords for the function. The function will automatically detect them and separate them to arguments and keywords:

a1 = "Bob"      #string
a2 = [1,2,3]    #list
a3 = {'a': 222, #dictionary
      'b': 333,
      'c': 444}

test(a1, a2, a3, param1=True, param2=12, param3=None)

Output:

arguments are:
Bob
[1, 2, 3]
{'a': 222, 'c': 444, 'b': 333}

keywords are:
param3
param2
param1
Answer from imz22 on Stack Overflow
๐ŸŒ
Codecademy
codecademy.com โ€บ learn โ€บ flask-introduction-to-python โ€บ modules โ€บ learn-python3-functions โ€บ cheatsheet
Introduction to Python: Functions Cheatsheet | Codecademy
For example, the function definition ... of a book. def write_a_book(character, setting, special_skill): ... Python functions can have multiple parameters....
Discussions

pass multiple parameters to a function from a single input
split() will turn the input into a list. You could then put a "*" in front of the input ... (*input( ... to unpack it but that's obfuscating the code. Instead I'd split that into 3 lines. First, input the string. Second, split the string and assign it to two variables, which automatically unpacks the list. Third, call the function with those two variables. More on reddit.com
๐ŸŒ r/learnpython
20
1
February 26, 2022
How to pass multiple tuples into a class.__init__()
I assume you want to pass each tuple as an argument to your function. You can do that with a *. Basically, this takes all of the arguments to your function and makes it accessible as a tuple. def foo(*some_tuples): for e in some_tuples: assert isinstance(e, tuple) # Ensure that e is of type tuple. assert len(e) == 2 # Assert that e is of length 2 print tuple # I'm just printing it; you'll want to do something with each tuple here. foo((1,2), (3,4), (5,6)) >>> (1,2) >>> (3,4) >>> (5,6) foo("foo") >>> AssertionError (because "foo" is type str, not type tuple.) foo(("foo","bar")) >>>("foo","bar") Edit: I forgot you wanted a class.__init__(). Updated version: class Foo(object): def __init__(self, *some_tuples): for e in some_tuples: assert isinstance(e, tuple) # Ensure that e is of type tuple. assert len(e) == 2 # Assert that e is of length 2 print tuple # I'm just printing it; you'll want to do something with each tuple here. Foo((1,2), (3,4), (5,6)) >>> (1,2) >>> (3,4) >>> (5,6) Foo("foo") >>> AssertionError (because "foo" is type str, not type tuple.) foo(("foo","bar")) >>>("foo","bar") More on reddit.com
๐ŸŒ r/Python
5
0
November 1, 2014
Passing function with multiple arguments to scipy.optimize.fsolve

You can't put the function() call in before the fsolve() call because it would evaluate first and return the result. You have to pass it the function handle itself, which is just fsolve. Also x has to be the first argument of the function.

import scipy.optimize as opt
args = (a,b,c)
x_roots, info, _ = opt.fsolve( function, x0, args )
More on reddit.com
๐ŸŒ r/Python
2
0
June 16, 2016
Function parameter as a tuple
I'd say that function arguments are already a tuple (when currying is not involved). Just not a first order one in most languages. Now that you mention it, treating them differently from other tuples might actually be the strange thing. At first glance, anyway. More on reddit.com
๐ŸŒ r/ProgrammingLanguages
77
54
December 5, 2021
๐ŸŒ
Python.org
discuss.python.org โ€บ typing
Support Function With Multiple Generic Parameters Same Type - Typing - Discussions on Python.org
July 11, 2024 - I would like to be able to type a function that has multiple parameters, with the same generic variable, that only checks if the later parameters are compatible with the first. Proposal I propose by adding a bind_first flag to TypeVar: T = TypeVar('T', bind_first=True) def eq(x: T, y: T) -> bool: ... eq(10, 11) # passes eq(10, "str") # fails This would be equivalent typing-wise to capturing the first argument in a generic class and then using that in a method, like: T = TypeVar('T') class...
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ how-to-pass-multiple-arguments-to-function
How to pass multiple arguments to function ? - GeeksforGeeks
July 3, 2024 - In the above program, the variable number of arguments are passed to the displayMessage() function in which the number of arguments to be passed is not predetermined. (This syntax is only used to pass non-keyword arguments to the function.) We can pass multiple keyword arguments to a python function without predetermining the formal parameters using the below syntax:
๐ŸŒ
Medium
medium.com โ€บ @1511425435311 โ€บ multiple-parameters-and-return-values-d241100e76f6
Exploring Multiple Parameters and Return Values in Python ๐Ÿ | by Miguel de la Vega | Medium
December 29, 2023 - The order of the arguments should match the order of the parameters. def add_numbers(a, b): return a + b result = add_numbers(5, 10) print(result) # Output: 15 ยท In this example, the add_numbers function accepts two parameters (a and b) and returns their sum. ... Tuples are immutable objects that can contain multiple values.
๐ŸŒ
Earth Data Science
earthdatascience.org โ€บ home
Write Functions with Multiple Parameters in Python | Earth Data Science - Earth Lab
January 28, 2021 - Write and execute custom functions with multiple input parameters in Python.
Find elsewhere
๐ŸŒ
Team Treehouse
teamtreehouse.com โ€บ library โ€บ functions-packing-and-unpacking โ€บ multiple-arguments-and-parameters
Multiple Arguments and Parameters (How To) | Functions, Packing, and Unpacking | Treehouse
If you give two parameters the same name the Python interpreter will send 1:19 ... I'll also change the function name to something that's more accurate. 2:02 ยท And finally, let's fix our function call to reflect the new function name and 2:09 ... And so, for the second argument I'll just pick the integer 10 to send.
Published ย  July 9, 2022
๐ŸŒ
Stack Abuse
stackabuse.com โ€บ bytes โ€บ pass-multiple-arguments-to-the-map-function-in-python
How to Pass Multiple Arguments to the map() Function in Python
September 21, 2023 - Note: Make sure that the number of arguments in the function should match the number of iterables passed to map()! ... No spam ever. Unsubscribe anytime. Read our Privacy Policy. In the example above, we've defined a function multiply() that takes two arguments and returns their product.
๐ŸŒ
Note.nkmk.me
note.nkmk.me โ€บ home โ€บ python
*args and **kwargs in Python (Variable-Length Arguments) | note.nkmk.me
May 12, 2025 - In Python, you can define functions that accept a variable number of arguments by prefixing parameter names with * or ** in the function definition. By convention, *args (arguments) and **kwargs (keyw ...
๐ŸŒ
Python documentation
docs.python.org โ€บ 3 โ€บ tutorial โ€บ controlflow.html
4. More Control Flow Tools โ€” Python 3.14.3 documentation
Finally, the least frequently used option is to specify that a function can be called with an arbitrary number of arguments. These arguments will be wrapped up in a tuple (see Tuples and Sequences). Before the variable number of arguments, zero or more normal arguments may occur. def write_multiple_items(file, separator, *args): file.write(separator.join(args))
๐ŸŒ
DataCamp
campus.datacamp.com โ€บ courses โ€บ intro-to-python-for-data-science โ€บ chapter-3-functions-and-packages
Multiple arguments | Python
In the previous exercise, you identified optional arguments by viewing the documentation with help(). You'll now apply this to change the behavior of the sorted() function.
๐ŸŒ
Python Morsels
pythonmorsels.com โ€บ accepting-any-number-arguments-function
Accepting any number of arguments to a function - Python Morsels
November 18, 2020 - To make a function that accepts any number of arguments, you can use the * operator and then some variable name when defining your function's arguments. This lets Python know that when that function is called with any positional arguments, they ...
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ python_args_kwargs.asp
Python *args and **kwargs
Remember: Use * and ** in function definitions to collect arguments, and use them in function calls to unpack arguments. ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: sales@w3schools.com ยท If you want to report an error, or if you want to make a suggestion, send us an e-mail: help@w3schools.com ยท HTML Tutorial CSS Tutorial JavaScript Tutorial How To Tutorial SQL Tutorial Python Tutorial W3.CSS Tutorial Bootstrap Tutorial PHP Tutorial Java Tutorial C++ Tutorial jQuery Tutorial
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ python_arguments.asp
Python Function Arguments
Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Bootcamp Python Certificate Python Training ... Information can be passed into functions as arguments.
๐ŸŒ
Python
docs.python.org โ€บ 3 โ€บ library โ€บ argparse.html
argparse โ€” Parser for command-line options, arguments and subcommands
Splitting up functionality this way can be a particularly good idea when a program performs several different functions which require different kinds of command-line arguments. ArgumentParser supports the creation of such subcommands with the add_subparsers() method.
๐ŸŒ
Medium
ogungbireadedolapo.medium.com โ€บ passing-multiple-arguments-into-pandas-apply-function-3d9cf89d95cc
Passing multiple arguments into Pandas Apply function | by Ogungbire Adedolapo | Medium
September 22, 2022 - More often than not, this will have the value 1 to help iterate over the rows. I hope this has been helpful to simplify the use of multiple argument in the pandas apply function. ... Data Science Professional with Domain Expertise in Transportation Planning and Design. Python, Java, SQL, Tableau.
๐ŸŒ
Boot.dev
boot.dev โ€บ lessons โ€บ 64266f19-9783-44c1-b63b-01f40ae9a0b8
Learn to Code in Python: Multiple Parameters | Boot.dev
Functions can have multiple parameters ("parameter" being a fancy word for "input"). For example, this subtract function accepts 2 parameters: a and b. ... It's the argument's position that determines which parameter receives it (at least, for now).
๐ŸŒ
DataCamp
campus.datacamp.com โ€บ courses โ€บ introduction-to-functions-in-python โ€บ writing-your-own-functions
Multiple parameters and return values | Python
The order in which the arguments are passed correspond to the order of the parameters in the function header. This means that when we call raise_to_power(2, 3), when the function is executed, 2 would be assigned to value1 and 3 to value2. Looking at the function body, this means that the computation value1 to the power of value2 translates to 2 to the power of 3. This function call then returns the value 8. You can also make your function return multiple values.