Ask coding questions

← Back to all posts
Patterns in Python
cheezburstpizza (0)

How can we make number patterns in python? Can someone explain code to me? codes such as/similar to this. Include explanation in comments(#) of python .I want to know about loop in a loop ,its functioning.
1
1 2
1 2 3


And

4 3 2 1
4 3 2
4 3
4

Comments
hotnewtop
Coder100 (16733)

Using loops like this:

l = list(range(1, 5))
l.reverse()

for i in range(len(l)):
  print(' '.join([str(i) for i in l[i:]]))