Skip to content

Commit

Permalink
Reto mouredev#16 - Python
Browse files Browse the repository at this point in the history
  • Loading branch information
ShinMugenNoKabe committed Jul 30, 2023
1 parent 0d9c842 commit ed71b6b
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions Retos/Reto #16 - LA ESCALERA [Media]/python/ShinMugenNoKabe.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
def draw_ladder(steps: int):
if steps == 0:
print('__')
return

left_to_right = steps > 0
range_step = -1 if left_to_right else 1

# Imprimir último escalón
if left_to_right:
print(f"{'_' : >{(steps * 2) + 1}}")
else:
print('_')

if left_to_right:
for i in range(steps, 0, range_step):
print(f"{'_|' : >{i * 2}}")
else:
for i in range(0, abs(steps), range_step):
print(f"{'|_' : >{((i * 2) + 3)}}")


if __name__ == "__main__":
draw_ladder(0)
print("--------")
draw_ladder(4)
print("--------")
draw_ladder(-7)

0 comments on commit ed71b6b

Please sign in to comment.