I would like to define a function that prints output of a triangle like this, when number of rows = 5.
*
*
* *
* *
* * *
currently, my code looks like this:
def triangle(n):
result = ''
for i in range(1, n+1):
result += ('*' * i)+'\n'
return result
however, it's not the way i want it to look. any ideas how I can improve this?