+ 1

Can anyone tell me wats wrong with this code?

https://code.sololearn.com/cBhfX5Lcy71y/?ref=app

10th Nov 2017, 10:12 PM
Hamza Boudouche
9 Answers
+ 3
Currently function pyramid prints a line but returns nothing i.e. None . Replace print with str since you want to return string not list. Also add 'return' before str, because you want the pyramid function to return the string value. short version: replace 'print' with 'return str' still you will not get a number pyramid, but I'll leave it up to you to figure that out :) spaces are reverse proportional to the n value. * str(arg) function converts arg to string
10th Nov 2017, 10:29 PM
Aleksas Pielikis
Aleksas Pielikis - avatar
+ 3
pyramid() doesn't have a return statement, so its returned value is 'None'
10th Nov 2017, 10:28 PM
Kirk Schafer
Kirk Schafer - avatar
+ 2
#I think you want like this. #pyramid of numbers x = int(input("input: ")) def pyramid(n): print(list(range(n+1))[::-1] + list(range(1, n+1))) for n in range(x+1): print(str(n)*(n)) pyramid(n)
10th Nov 2017, 10:37 PM
Ferhat Sevim
Ferhat Sevim - avatar
+ 2
#Or like this? #pyramid of numbers x = int(input("input: ")) print() def pyramid(n): print(list(range(n+1))[::-1] + list(range(1, n+1))) return n for n in range(x+1): print((" "*(n-1),pyramid(n)))
10th Nov 2017, 10:46 PM
Ferhat Sevim
Ferhat Sevim - avatar
+ 2
I think I figured it out #pyramid of numbers x = int(input("input: ")) def pyramid(n): return str(list(range(n+1))[::-1] + list(range(1, n+1))) for n in range(x+1): print(" "*(x-n) + pyramid(n))
10th Nov 2017, 10:49 PM
Hamza Boudouche
+ 2
šŸ‘ just add one empty print() under input() or \n to input
10th Nov 2017, 10:53 PM
Ferhat Sevim
Ferhat Sevim - avatar
+ 1
@Ferhat sevim not exactly but thanks anyway
10th Nov 2017, 10:41 PM
Hamza Boudouche
+ 1
šŸ‘ thanks
10th Nov 2017, 10:54 PM
Hamza Boudouche
11th Nov 2017, 1:06 PM
Aleksas Pielikis
Aleksas Pielikis - avatar