Number Pattern 3
Level EASY
Print the following pattern for the given N number of rows.
Pattern for N = 4
Input format :
Output format :
Sample Input :
Sample Output :
1
11
121
1221
12221
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Read input as specified in the question. | |
## Print output as specified in the question. | |
num=int(input()) | |
for i in range(1,num+1): | |
for j in range(0,i): | |
x=i-1 | |
if x==0: | |
print(1,end="") | |
else: | |
if x==j or j==0: | |
print(1,end="") | |
else:print(2,end="") | |
print("") |
nice
ReplyDelete