Print the first parameter

Created by Julien Palard

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 your computer. Learn how for Mac OSX or Windows.

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

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

There's no corrections yet, hit the `Submit` button to send your code to the correction bot.

Keyboard shortcuts:

  • Ctrl-Enter: Send your code to the correction bot.
  • Escape: Get back to the instructions tab.

See solutions