I can't seem to fix my problem. I have a list of letters I am outputting, which works fine. Now, I want to get it into a pyramid shape...
The error I am getting, is this:
TypeError: can't multiply sequence by non-int of type 'str'
for letter in range(102,latest_letter):
print(first_part_of_letters(letter) *' ' + second_part_of_letters(letter-2)) * '* '
As I believe that it is in continuation to the question you asked How make this for loop work?. I am updating the logic in my original answer that I mentioned there, to generate the pyramid. The idea to get that output to be printed in the form of pyramid is to multiply
' ' based on the position of your alphabet. Hence, it could be written as:
import string alphs = string.ascii_lowercase # returns string of lower case characters last_letter = 'f' index = alphs.index(last_letter) # get index of the `last_letter` for i in range(index): print ' '*(index-i-1), alphs[:i]+alphs[i::-1] # ^ print ` ` blank space based on the value of `index - i-1`
which print the output as:
a aba abcba abcdcba abcdedcba