I want to make sure 'rep' isn't made 0 at the beginning of each recursion. At the current point it is defaulted to starting at 0, but I want it to save the value of rep+=1.
Is there an easy fix?
def printPattern(n,k,rep =0):
'prints a pattern of stars'
if n == k:
print ('{}{}'.format(' '*rep,'*'*n))
elif n%2 == 0:
rep+=1
print ('{}{}'.format(' '*rep,'*'*n))
printPattern(n+1,k)
else:
rep+=1
print ('{}*'.format(' '*rep))
printPattern(n+1,k)