Little Help(Not getting output here) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Little Help(Not getting output here)

QUESTION: Your teacher has given you the task to draw the structure of a staircase. Being an expert programmer, you decided to make a program for the same. You are given the height of the staircase. Given the height of the staircase, write a program to print a staircase as shown in the example. For example, Staircase of height 6: # ## ### #### ##### ###### Boundary Conditions: height >0 , Program to be solved by using while loop only. MY CODE: n=int(input()) for i in range(0,n): for j in range(0,n+1): if i+j>=n-1: print('#', end='') else: print(" ",end='') print()

3rd Oct 2021, 1:47 AM
Saurav Singh
Saurav Singh - avatar
1 Answer
+ 5
Hi Saurav! You're supposed to solve this challenge using while loop(since they mentioned it at the end). For that, you just have to consider using an additional variable to run the loop properly. n = int(input()) i = 1 while n>=i: print("#"*i) print() i += 1 But if you want to do it using for loop it needs to be like this n=int(input()) for i in range(1,n+1): print("#"*i) print()
3rd Oct 2021, 1:59 AM
Python Learner
Python Learner - avatar