Space Python Loading Python…

Variable Number of Arguments *args

 
0:00 / 0:00

Challenge

Practise what this example shows: fix or write code until the tests pass.

Any number of values

Write the codeEasy 2 stages

Write average(*values), which accepts any number of numbers, call it with loose values and with a list unpacked by *, then add a keyword-only decimals option after *values and return None when there are no values.

Start the challenge

Discussion

Stuck on this example or want to go further? Ask here, or see what others asked.

Log in to ask and reply.

script.py
PythonLn 1, Col 1Spaces: 4
Loading the Python environment…

Separate arguments with commas. They're passed on every Run as sys.argv[1:].