Skip to content

Commit 688fbbd

Browse files
committed
added generate_inputs to "strings of equal length" exercise
1 parent 17fabd3 commit 688fbbd

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

backend/main/chapters/c08_nested_loops.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# flake8: NOQA E501
22
import ast
3+
from string import ascii_lowercase
4+
from random import randint, choice
35
from typing import List
46

57
from main.exercises import generate_string
@@ -1581,6 +1583,15 @@ def solution(self, strings: List[str]):
15811583
line += string[i]
15821584
print(line)
15831585

1586+
@classmethod
1587+
def generate_inputs(cls):
1588+
strlen, listlen = randint(1, 10), randint(1, 10)
1589+
letters = ascii_lowercase + ' '
1590+
strings = [''.join([choice(letters) for _ in range(strlen)]) for _ in range(listlen)]
1591+
return dict(
1592+
strings=strings,
1593+
)
1594+
15841595
hints = """
15851596
You'll need to go through the first letters, then the second letters, and so on.
15861597
You'll have to use a loop, but how long should the loop take?

0 commit comments

Comments
 (0)