Advertisement
Programmin-in-Python

Unique Pattern-printing in Python

Oct 24th, 2021
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.22 KB | None | 0 0
  1. n = int(input("Enter the value of N :"))
  2. res = "1"
  3.  
  4. for i in range(n+1):
  5.     for j in range(i):
  6.         if res[-1] == "0":
  7.             res += " 1"
  8.         else:
  9.             res += " 0"
  10.  
  11.     print(res)
  12.     res = "1"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement