1
I am trying to make a program that given a value, generates a "square" of n rows and n columns that has characters :
in the main diagonal positions and the characters +
in other positions.
For example, n = 5:
:++++
+:+++
++:++
+++:+
++++:
The logic is correct, however, I’m having trouble formatting the square. Can someone please help me?
n = 0
i = 0
j = 0
n = int(input("Digite um número: "))
if n > 0:
print("Desenho")
for i in range(1, n):
for j in range(1, n):
if i != j:
print("+", end="")
else:
print(":", end="")
print()
else:
print("Numero menor ou igual a zero, programa abortado!")
It worked fine, thank you very much!!!
– Matheus Guerreiro
@Matheusguerreiro If the answer solved your problem, you can accept it, see here how and why to do it. It is not mandatory, but it is a good practice of the site, to indicate to future visitors that it solved the problem. And when I get 15 points, you can also vote in response if it has found it useful
– hkotsubo