I have this activity where I have to use star growth in a string where it grows with the amount of a character in the string. Here is an example: star_match_growth("incandescent", "c") and have it return as: inc*andesc**ent and have it continue if there are any more c's in the string. This is what I have to far:
def star_match_growth(word, letter):
builder = ""
for i in range(0, len(word)):
word_2 = word.replace(letter, str(star_growth(word.count(letter))))
return word_2
def star_growth(top):
word = top * "*"
builder = ""
for i in range(1, len(word) + 1):
builder += word[0:i] + " "
return builder[:-1]
print(star_match_growth("incandescent", "c"))
and the output is:
inc* **andesc* **ent
Note it also has to ignore capitalization Note I'm also not allowed to import anything into the code iteself