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 | 1859+ Python FAQs | Share
frozenset | max-min | init | int | goto-function | syntax | multiple-inheritance | operand | numeric | descriptors | math-copysign | python-operators | complex-number | import-method | introduction-to-multiprocessing | loop | python-repl | decimal | lambda-functions | objects | postfix | copy | pseudocode | loop-control | multiprocessing | comment | operators | complex | assignment-operator | application | reading-and-writing-large-files-efficiently | error-handling | quantifiers-(*,-+,-?,-{}) | class-and-instance-variable | multiple-inheritance | list-indexing | list-join | defining-functions | pandas | operator-or | dictionary | reading-and-writing-files | global-variable | python_version | debugging | functional-programming | range | operator | print-statement | conditional-statement | opening-files-(open()) | advanced-file-operations | design-principle | parsing-with-strptime | arithmetic-expression | indentation | map-function | mysql | time-series-with-pandas | yield | anchors-(^,-$) | virtual-environment | min-max-function | single-inheritance | creating-and-starting-threads | for | built-in-function | random-function | method-overloading | implementation | dictionary-methods | filtering-and-indexing | variable | function-and-scope | swapping | identity-operator | file-handling | integer | string-manipulation | counter-function | escape-operator | walking-through-directories-using-os.walk() | lambda-function | while-loop | higher-order-function | list-method | multiple-except-blocks | type-conversion-and-casting | default-mutable-argument | using-map()-for-transformations | recursion | static-method | data-structure | aggregating-data-with-functools.reduce() | matrix-list-comprehension | statement | data_structure | iterable | parameter | matplotlib | logical-operator | membership-operators-(in,-not-in) | working-with-binary-files-(rb,-wb) | dataframe-and-series-objects | indexing | type-conversion | name-mangling | matrix | call | introduction-to-threads | python-django | using-else-and-finally | invalid-list | list-comprehension | strings | with-statement | python-history | round-function | floating-point-precision | binary | access-modifier | global | random | syntax-error | tuple | docstring | data-type-conversions | keyword | sys | typeerror | multithreading | immutability | context-manager | software-design | error | using-lists-as-stacks | working-with-file-paths | __init_subclass__ | default-arguments | bitwise-operator | binary-operation | string-methods | assignment-operators | string | datatype | introduction-to-python | precedence | loop-control-statements | classes | zip-function | namedtuple | version | data-types | global-keyword | encoding | input-function | turtle | formal-and-actual-parameter | filter-function | data-type | immutable-data-type | __all__-attribute | choice | thread | sorted | conditional-statements | rollback | tuple-methods | expression | lists | exception | boolean-masking | attribute | filter | recurssion | deep-copy | using-yield-in-functions | list | encapsulation | sum() | list-methods-and-slicing | lambda | functions | oop | logical-operator | data-structures-in-python | control-flow | format | nested-loop | pickling--unpickling | conditional-statement | bitwise | directory-operations | virtual-environment | syntax-error | touples | operator-and | id-function | slicing | inheritance | list-operation | booleans | syntaxerror | mathematical-function | while-and-for-loop | string-formatting | interpreter | else | while-loops | operator-overloading | feature | counter | precedence-and-associativity | indexing:-loc-vs-iloc | polymorphism | comparison | exception-handling | split | stack | oops | math | pep | lambdas | exception-handling | comprehension | library | python-syntax-and-structure | raise | namespace | list-slicing | identifier | raise-statement | data-structures | key-value-pairs | list-vs-tuple | integers | __future__ | sorting | string-formatting | class-decorators | identity-operator | factorial-function | dictionary-comprehensions | writing:-write(),-writelines() | string-iteration | why-use-multiprocessing-over-threading?-(gil) | thread-synchronization | global-variable | array | datetime | test-discovery | list-comprehensions | methods | zfill-function | boolean-and-non-boolean | magic-method | staticmethod | expand-tab | while-else-loop | string-concatenation | generators | intering | method | file | mutable | print | input-function | else-statement | basic | operations | generators-in-python | input | compute | async | regular-expression | constructor | thread-safe-data-structures-(queue.queue) | literal-characters-and-special-characters | slice | datetime.date,-datetime.time,-datetime.datetime | function-argument | object-attribute | condition | collection | regex | python-module | formatting-with-strftime | identity-operators-(is,-is-not) | loops | memory | enumerate() | logical-operators | python | list-comprehension | installation | using-the-threading-module | exponentiation | memory-management | boolean | benefit | mapping-function | module | overflow | heap-memory | destructor | odd-number | arbitrary-arguments-(*args,-**kwargs) | list-mutation | creating-custom-modules | package-management | built-in | return-statement | asyncio | def | working-with-temporary-files-using-tempfile | pass | round | inherit | built-in-function | iterators | tuple-unpacking | append | regular-expressions | mathematics | join | file_handling | head-and-tail | joining-and-merging-dataframes | using-assertions-(assertequal,-assertraises) | shallow-copy | set | string-slicing | class | built-in-modules | threading | iterator | control-flow | tuples | difference-between-threads-and-processes | logical-operation | sum-function | conversion | zip | set-operation | unit-testing | handling-missing-values-(fillna,-dropna) | generator | file-handling | function | type-conversion | functional-programming | decorator | error-handling | center | floats | dicts | sorting-and-ranking | gil | string-method | type_conversion | scientific-notation | using-join()-and-is_alive()-methods | version-check | reading:-read(),-readline(),-readlines() | update | bitwise-operator | working-with-dates-and-times | fabs-function | assert | asyncio-module | sets | match | class-and-object | string-method | using-os-and-pathlib-modules | managing-directories-with-os-and-shutil | collections | min-function | list,-set,-and-dictionary-comprehensions | arithmetic-operation | control-statement | class-and-inheritance | string-slicing | overriding-methods | data-type | data-structure | command-line-parsing | numpy | sys-module | dictionaries ...