0

Python provides an inbuilt function 'print' which h automatically generates a line break when it is called, then how can we generate a pattern as : 1 2 2 3 3 3 4 4 4 4 and so on.. using while loop ???

18th Oct 2016, 8:27 AM
Piyush Bhatia
Piyush Bhatia - avatar
2 Answers
+ 2
i=1 j=1 while i<=4: j=1 while j<=i: print(j, end=" ") j+=1 #End of body of 2nd while loop #print("\n") #in the body of 1st while loop i+=1
18th Oct 2016, 8:40 AM
Shahid Islam
Shahid Islam - avatar
0
i = 1 n = 7 while i < n: print(str(i) * i) i += 1
19th Oct 2016, 5:06 AM
Luke Armstrong