Level 5 : What is the purpose of the *args syntax in a function definition?


def example_function(*args):
    for arg in args:
        print(arg)

example_function(1, 2, 3)

Author: IndraD | Tags: function | 1736+ Python FAQs | Share
package-management | data-structure | list-slicing | goto-function | format | iterable | object-attribute | command-line-parsing | decimal | encoding | escape-operator | context-manager | library | global-keyword | objects | module | type_conversion | slice | immutability | split | type-conversion | global-variable | global | lambda-function | name-mangling | namespace | match | append | version-check | collection | mysql | python_version | datatype | comment | design-principle | sys | filter-function | type-conversion | def | dictionaries | fabs-function | math | round-function | classes | conditional-statement | statement | map-function | while-and-for-loop | math-copysign | list-vs-tuple | sum() | binary | feature | scientific-notation | zip | higher-order-function | dictionary | sorted | typeerror | join | __all__-attribute | decorator | odd-number | class | functional-programming | parameter | asyncio | destructor | list | method | expand-tab | descriptors | file_handling | arithmetic-expression | call | multiprocessing | recurssion | while-else-loop | string-concatenation | mutable | random | lambdas | heap-memory | string-method | precedence-and-associativity | logical-operator | tuple-unpacking | matplotlib | frozenset | while-loop | syntax-error | syntaxerror | lambda | deep-copy | file-handling | collections | syntax | data-structure | comprehension | built-in-function | function-argument | file | list-comprehension | built-in-function | installation | string-iteration | else-statement | function-and-scope | for | keyword | multithreading | constructor | version | memory | file-handling | pickling-&-unpickling | floating-point-precision | enumerate() | string-formatting | string-formatting | bitwise-operator | python-history | loop-control | exponentiation | async | staticmethod | magic-method | function | encapsulation | generators | memory-management | generator | implementation | software-design | compute | counter-function | conversion | condition | exception-handling | bitwise | invalid-list | datetime | head-and-tail | loop | bitwise-operator | identity-operator | binary-operation | nested-loop | assert | __init_subclass__ | max-min | import-method | input-function | int | string-manipulation | virtual-environment | class-and-inheritance | return-statement | list-operation | matrix | generators-in-python | round | gil | update | polymorphism | indentation | data_structure | sum-function | center | mathematical-function | lists | id-function | copy | postfix | shallow-copy | oops | with-statement | input | expression | range | pandas | access-modifier | comparison | exception-handling | loops | arithmetic-operation | pseudocode | syntax-error | oop | debugging | inheritance | string-method | logical-operation | class-and-instance-variable | choice | touples | basic | turtle | set | identity-operator | variable | operand | error | formal-and-actual-parameter | list-method | assignment-operator | default-mutable-argument | python-repl | operations | min-max-function | mathematics | random-function | filter | data-type | list-comprehension | string-slicing | error-handling | print | input-function | attribute | docstring | boolean-and-non-boolean | virtual-environment | python-django | numpy | precedence | iterator | integer | array | immutable-data-type | indexing | logical-operator | benefit | list-join | numeric | python-module | global-variable | built-in | list-indexing | python | identifier | operator-or | conditional-statement | data-structures | namedtuple | boolean | zip-function | yield | regular-expression | matrix-list-comprehension | complex-number | operator | control-flow | pep | data-type | init | operator-and | stack | list-mutation | set-operation | interpreter | mapping-function | threading | regex | sys-module | overflow | complex | inherit | methods | slicing | thread | swapping | string-slicing | static-method | asyncio-module | operator-overloading | application | control-flow | sorting | operators | zfill-function | control-statement | __future__ | factorial-function | print-statement | string | tuple | class-and-object | multiple-inheritance | counter | raise | rollback | dicts | exception | min-function | recursion | functions ...