logo CodeStepByStep logo


Language/Type: Python recursion

Write a recursive function named write_nums that accepts an integer n as a parameter and prints to the console the first n integers starting with 1 in sequential order, separated by commas. Your function should raise a ValueError if passed a value less than 1. For example, the call of write_nums(5) should produce the following output:

1, 2, 3, 4, 5
Function: Write a Python function as described, not a complete program.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.