I was learning nested loops, and ran into this problem with line spacing between each of x's lines.
numbers = [2, 2, 2, 2, 7, 7]
for i in numbers:
for j in range(0, i):
print("x", end='')
print('\n')
Following is the output of my code:
xx
xx
xx
xx
xxxxxxx
xxxxxxx
What changes should I make in my code so that an additional line is not present between each x's line?
Replace print("\n")
with print()
, as print already prints a trailing newline by default.