forked from mouredev/retos-programacion-2023
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request mouredev#3114 from tecfer/main
Reto mouredev#16 - Python
- Loading branch information
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
|