New line when using % formatting in python -
i'm trying print new line while using % formatting. code have:
return '%s\n%s\n%s\nscore: %d' % (seqa, matches, seqb, score)
but prints:
'attcgt\n|| |\natctat\nscore: 2'
is there way print new lines using method?
use print
instead of return
. print
evaluates each expression , writes result standard output, whereas return
merely echoes returned object (in idle):
>>> seqa = 'attcgt' >>> matches = '|| |' >>> seqb = 'atctat' >>> score = 2 >>> print '%s\n%s\n%s\nscore: %d' % (seqa, matches, seqb, score) attcgt || | atctat score: 2
Comments
Post a Comment