logo CodeStepByStep logo

random_x

Language/Type: Python random loops
Related Links:

Write a function named random_x that keeps printing lines, where each line contains a random number of x characters between 5 and 20 inclusive, until it prints a line with 16 or more characters. For example, the output from your function might be the following. Notice that the last line has 17 x characters.

xxxxxx
xxxxxxxx
xxxxx
xxxxxxxxxxx
xxxxxxx
xxxxxxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxxxxxxxxxx

(Because this problem uses random numbers, our test cases check only the general format of your output. You must still examine the output yourself to make sure the answer is correct.)

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.