Currently, the stars function takes i , namely, how many stars are printed, and then extracts from the global variable s for which character to print.
Instead, parameterize s in stars so that you can specify a function whose symbol will be printed every time it is called.
def starts(i, s): print(s * i)
Then in triangle_of_symbols go s together with i+1 .
... for i in range(n): stars(i+1, s)
although there really is a small reason for separating the two functions.
def triangle_of_stars(s, n): for i in range(n): print(s * i+1)
source share