How do you write a program in python that creates pyramids based on user input? -


write program input height , outputs triangle of numbers given height:

  • each line should contain positive integer n​ denoting height of 1 triangle
  • inputting -1 should terminate value
  • output blank line after every test case

    sample input: 3 2 4 -1 sample output: 1 12 123  1 12  1 12 123 1234 

this code

inp = [] while true:     = int(input())     if == -1:         break     inp.append(i)  def pyramid(n):     return [list(range(1, i+1)) in range(1, n + 1)]  result = [pyramid(i) in inp] in result:     j in i:         print(j)     print('\n') 

Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -