-
Notifications
You must be signed in to change notification settings - Fork 3k
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 #3485 from RubenMkda/main
Reto #20 - Python
- Loading branch information
Showing
1 changed file
with
31 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,31 @@ | ||
def trifuerza(rows): | ||
|
||
for n in range(1, rows*2+1): | ||
|
||
formule = 2*n-1 | ||
formule2 = rows*2 | ||
spaces = rows*2-n | ||
|
||
# Draw top triangle | ||
if n <= rows: | ||
print(" "*spaces + "*"*(formule)) | ||
|
||
# Draw bottom triangles | ||
if n > rows: | ||
print(" "*spaces + "*"*( formule - formule2 ), end="") | ||
print(' '*(formule2-n+spaces+1), end='') | ||
print("*"*(formule-formule2)) | ||
|
||
if __name__ == "__main__": | ||
|
||
while True: | ||
|
||
rows = input("Por favor ingrese el numero de filas: ") | ||
if rows.isdigit(): | ||
rows = int(rows) | ||
print("Trifuerza: ", rows) | ||
trifuerza(rows) | ||
break | ||
|
||
else: | ||
print("El numero debe ser un número entero. Intente de nuevo.") |