print recursive pattern without quotes in python -
my code pattern:
def pattern(n): if n==1: return '1' else: return pattern(n-int(n/2))*2+str(n) print(pattern(n))
i need:
>>> pattern(1) 1 >>> pattern(2) 112 >>> pattern(4) 1121124 >>> pattern(8) 112112411211248
but get:
>>> pattern(1) '1' >>> pattern(2) '112' >>> pattern(4) '1121124' >>> pattern(8) '112112411211248'
i have tried lot nothing working rid of pesky quotes.
the quotes repl printing representation of result of function call, string. if not want representation print result explicitly instead.
Comments
Post a Comment