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