Exceptions

Created by Julien Palard

Description

This is a rapid introduction about Exception.

In this exercice you'll just have to print the first argument passed to the script:

print(sys.argv[1])

But without actually checking if len(sys.argv) is long enough to have it.

So, sometimes, it will fail with an IndexError.

You'll have to catch this IndexError and print:

Not enough parameters.

Advice

I'll search for any occurence of if in your code. If found, I'll reject your solution, so use try.

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