Skip to content

Commit

Permalink
Update solution.py
Browse files Browse the repository at this point in the history
suggestion (code-quality): Convert for loop into list comprehension (list-comprehension)
  • Loading branch information
ikostan committed Dec 25, 2024
1 parent c554733 commit bee5ccc
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions kyu_7/complete_the_pattern_5_even_ladder/solution.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ def pattern(n: int) -> str:
# If any odd number is passed as argument then the pattern
# should last up to the largest even number which is smaller
# than the passed odd number.
lines: list = []
for i in range(2, n + 1, 2):
# Note: There are no spaces in the pattern.
lines.append(f'{i}' * i)
# Note: There are no spaces in the pattern.lines.append()
# Use \n in string to jump to next line.
lines: list = [(f'{i}' * i) for i in range(2, n + 1, 2)]
return '\n'.join(lines)

0 comments on commit bee5ccc

Please sign in to comment.