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