> 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 %}
