Skip to content

Commit

Permalink
Merge pull request mouredev#3114 from tecfer/main
Browse files Browse the repository at this point in the history
Reto mouredev#16 - Python
  • Loading branch information
Roswell468 authored Apr 19, 2023
2 parents 907a442 + 3b50476 commit b630514
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions Retos/Reto #16 - LA ESCALERA [Media]/python/tecfer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
'''
* Crea una función que dibuje una escalera según su número de escalones.
* - Si el número es positivo, será ascendente de izquiera a derecha.
* - Si el número es negativo, será descendente de izquiera a derecha.
* - Si el número es cero, se dibujarán dos guiones bajos (__).
*
* Ejemplo: 4
* _
* _|
* _|
* _|
* _|
*
'''


def main():

steps = int(input("Introduce número de escalones: "))
up = "_|"
down = "|_"

if steps>0:
print(" "* (steps+1) + "_")
for step in range(steps,0,-1):
print(" "*step + up)
elif steps<0:
print(" _")
for step in range(-1,steps-1,-1):
print(" "*(-1*step) + down)
else:
print("__")

if __name__ == '__main__':
main()

0 comments on commit b630514

Please sign in to comment.