Staircase detail
This is a staircase of size: n = 4
#
##
###
####
Note: Right-aligned #
Its base and height are both equal to n. It is drawn using # symbols and spaces. The last line is not preceded by any spaces.
Query: Write a program that prints a staircase of size n.
Function Description
The staircase has the following parameter(s):
int n: an integer
Print a staircase as described above.
Input Format
A single integer, n, denoting the size of the staircase.
Code language => Python
Solutions:
def staircase(n): l = n for x in range(0,l): ns = l-x -1 print(ns * " "+("#")*(x+1)) staircase(6) # output # ## ### #### ##### ######
Note:
In python, we can multiply a string. eg,
=> “ab” * 2
=> abab
From above we can multiply the “ab” 2 times. So, we use the same concept to print space.