I need help with my recursion code below. The code is suppose to print out an * followed by an i for every n. I realize that my base case might be incorrect and that it might be the reason for the string quotes in the output, but when I try to set the base case to return 0 or n, I get the error stating that I cannot convert integer into string implicitly.
def printPattern(n):
if n == 0:
return('')
else:
return('*' + printPattern(n-1) + 'i')
My output:
>>> printPattern(3)
'***iii'
Output I need (without the string quotations):
>>> printPattern(3)
***iii
Any ideas? Am I using the wrong logic here? Should I be going a different path with my code or is there anyway I can format the output to remove the string quotations?
print printPattern(3)