loops - How to ignore the next line in python -
i trying print this
* * * * * * * * * *
here code
while 1: n=int(input("enter n")) if n<3: print("wrong input") continue else: in range(1,n+1): j in range(1,i+1): print("x")
i refer question not able achieve this. can please me how can achieve this? thank you
example:
for in range(5): print('* '* i) * * * * * * * * * *
edit
or use map
functions faster:
print('\n'.join(map(lambda x: '* ' * x, range(5))))
timing
in [25]: %timeit print('\n'.join(map(lambda x: '* ' * x, range(5)))) 1000 loops, best of 3: 289 per loop in [26]: %timeit in range(5): print('* '*i) 1000 loops, best of 3: 444 per loop
Comments
Post a Comment