I have been practicing with some simple Python 3x exercises that I got on the web, they are about nested for loops that draw geometric figures, however, there is one that I can not solve for more attempts I have made. The exercise goes like this:
Write a program that asks for the width and height of a rectangle and what draw with asterisk characters "*" and hyphen "-":
Width: 6
Height: 4
The output should be something like this, a rectangle of asterisks filled with hyphens:
"* * * * * *
* - - - - *
* - - - - *
* * * * * * "
However my code gives me this output:
"* * * * -
* * * * -
* * * * -
* * * * -
* * * * -
* * * * -
* * * * - "
Here I put my code in Python 3.6:
alto=int(input("Introduce la altura:"))
largo=int(input("ahora la longitud:"))
for a in range(alto):
for l in range(1,largo):
print("*",end=" ")
print("-")
Thank you very much.