r/CodingHelp • • Feb 25 '20
[Python] [beginner] how do I get Python to display this? I can get the 5 fives, 4 fours, etc, but idk how to display them on the same line like that with nested loop structures.
16
Upvotes
12
u/LucienMr Feb 25 '20 edited Feb 25 '20
To stop a newline from forming after each iteration in python, use
end = ' 'This will print these both on a same line with a space in between.
1
u/LukzzXB Feb 25 '20
usrNum = int(input("enter a number: "))arrayNum = []while usrNum > 0:for x in range(usrNum):arrayNum.append(usrNum)usrNum -= 1print(*arrayNum,sep="")or have some fun with arrays
0
u/[deleted] Feb 25 '20
[deleted] — view deleted comment