python with for loop -
this question has reply here:
how maintain python print adding newlines or spaces? 14 answershey i've got problem loop, allow want accomplish printing "#" signs 5 times loop out space , in 1 line.
for in range(5): print "#",
can how ride of space in between looks ##### instead of # # # # #???
i assume plan on doing things in loop other printing '#', if case have few options options:
import sys in range(5): sys.stdout.write('#')
or if determined utilize print:
for in range(5): print "\b#",
or:
from __future__ import print_function in range(5): print('#', end='')
if want print '#' n
times can do:
n = 5 print '#'*n
or:
n = 5 print ''.join('#' _ in range(n))
python loops for-loop space
No comments:
Post a Comment