← Previous Next →

Print the first parameter

Created by Julien Palard

Instructions

Write a script that print the first parameter given to the script.

Warning

You should work on this exercise with your own installation of Python, on you computer. Learn how for Mac OSX or Windows.

If there is no parameters given, it should print the following error message:

usage: python3 solution.py PARAM

Advice

Maybe you'll need to import a few modules in your program.

Example

julien@localhost$ python3 solution.py antoine
antoine
julien@localhost$ python3 solution.py julien
julien
julien@localhost$ python3 solution.py
usage: python3 solution.py PARAM
julien@localhost$

references

if: https://docs.python.org/3/reference/compound_stmts.html#if

sys.argv: https://docs.python.org/3/library/sys.html#sys.argv

len: https://docs.python.org/3/library/functions.html#len