Objective
Create a Python program that reads its command-line arguments with sys.argv from the sys module. The arguments of each test are passed to the program as if you typed them in the terminal (they appear in the test cases).
Instructions
sys.argvis a list: element 0 is the name of the program, 1 is the first argument, 2 the second, etc.- The first argument is a name and the second (optional) is how many times to greet; if not given, it is 1.
- Show
Hello, nameas many times as requested, one per line. - If no argument is received, show
Usage: program name [times]and finish with exit code 1 usingsys.exit(1).
Hello, Ana
Hello, Ana
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise