+ 2

Can we make string triangle code into string pyramid ? But how?

python 3 code https://code.sololearn.com/cLAQ4wU9zrlw/?ref=app

17th Oct 2018, 4:27 AM
Ramesh Chakraborty
Ramesh Chakraborty - avatar
5 Respostas
+ 4
It still looks line a triangle to me. Anyway, I added a line and a character to your code, and it should work now. string = input("Enter a string \n") length = len(string) for row in range(length): print(" "*(length-row-1), end="") for col in range(row+1): print(string[col],end=" ") print()
17th Oct 2018, 5:41 AM
Kishalaya Saha
Kishalaya Saha - avatar
+ 4
for p in range(len(string)): print(" "*(len(string)-p-1) + " ".join(list(string[:p+1])))
17th Oct 2018, 6:33 AM
Flandre Scarlet
Flandre Scarlet - avatar
+ 1
example:- * * * * * * * * * * * * * * * * * * * * *
17th Oct 2018, 5:21 AM
Ramesh Chakraborty
Ramesh Chakraborty - avatar
+ 1
another example is p p y p y t p y t h p y t h o p y t h o n
17th Oct 2018, 5:29 AM
Ramesh Chakraborty
Ramesh Chakraborty - avatar
0
What's a string pyramid? Could you please give an example?
17th Oct 2018, 5:09 AM
Kishalaya Saha
Kishalaya Saha - avatar