Print this on Python -
0
1 1
2 2 2
3 3 3 3
4 4 4 4 4
Answers
Answered by
18
Answered by
11
Answer:
for I in range(0,5):
⠀⠀for j in range(0,I+1):
⠀⠀⠀⠀print(I,end=" ")
⠀⠀⠀⠀#numbers are same in each row so I will print I
⠀⠀print()
One-liner Approach:-
print("\n".join((str(i-1)+" ")*i for I in range(1,6)))
Variable Description:-
- I,j :- both are loop variable
Always Remember:-
- By default, loop starts from 0 so you can also write for I in range(5):
- By default, increment value is 1 so no need to write the increment value in the loop until you want increment value more than 1
•Output Attached.
•••♪
Attachments:
Similar questions