> For the complete documentation index, see [llms.txt](https://docs.arkannis.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.arkannis.net/programming/courses/python-pcap-31-03-course/functions-and-variable-scope/args-and-kwargs.md).

# \*args and \*\*kwargs

## Sending an unlimited amount of args to a function

`*args` = arguments&#x20;

`**kwargs` = keyword arguments

```python
result = sum((1,2,3,4,5)) # Using a tuple
# prints 15
```

#### Defining your own function with unlimited args

**args:**

```python
# Limited function
def my_sum(a,b,c,d):
	return(a+b+c+d) # Limited to amount of args
# Adding an extra arg will retun
# takes 4 positional args but 5 were given


# Unlimited function
def my_sum(*args):
	return sum(args) # Sums unlimited amount of numbers
```

**kwargs:**

```python
def key_value_func(**kwargs): # Requires variable name and value
	print(kwargs)
	
# ALWAYS USES KEY VALUE PAIRS
key_value_function(name="mike", weight=200, age=27):
	print(kwargs.keys())        # This will print only the keys
	print(kwargs.values())      # This will print only the values
	print(kwargs.get("weight")) # This will get the value of the key
# Prints the key value pairs in a DICTIONARY
```

{% hint style="info" %}
**NOTE:** `None` is a value in python which represents the idea of nothing
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.arkannis.net/programming/courses/python-pcap-31-03-course/functions-and-variable-scope/args-and-kwargs.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
