Python: doubling variable in a function -
def lb(a): while != 0: = - 1 print('\n') print('1 line break') lb(1) print('2 line breaks') lb(2) print('3 line breaks') lb(3) print('done')
when run code doubles amount of lines needs break, outputs: 1 line break 2 line breaks 3 line breaks
how make print right amount of line breaks?
in python print
automatically adds line break @ end unless explicitly told not to. means function print twice number of line breaks asked because
print('\n')
prints 2 line breaks, 1 in string , added automatically @ end.
a simple solution use print()
instead.
Comments
Post a Comment