logo CodeStepByStep logo

spaced_numbers2

Language/Type: Python basics for loops

Modify your code from the previous exercise to make a new function named spaced_numbers2 that could easily be modified to display a different range of numbers (instead of 1234567890) and a different number of repetitions of those numbers (instead of 60 total characters), with the vertical bars still matching up correctly. At the top of your code, outside of your function, declare two constants named MAX and TIMES. Use these throughout your code instead of "magic numbers" to scale the output. Here are some example outputs that could be generated by changing your constants:

MAX = 5
TIMES = 10

|    |    |    |    |    |    |    |    |    |
12340123401234012340123401234012340123401234012340
MAX = 8
TIMES = 7

|       |       |       |       |       |       |
12345670123456701234567012345670123456701234567012345670
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.