How to repeat a string N times and N lines in Python

1 Answer

0 votes
def f(s, n):
    print((((s * n) +'\n') * n)[:-1])


f('python ', 5)



'''
run

python python python python python 
python python python python python 
python python python python python 
python python python python python 
python python python python python 

'''

 



answered Apr 9, 2019 by avibootz

Related questions

2 answers 364 views
3 answers 323 views
323 views asked Apr 24, 2021 by avibootz
1 answer 198 views
1 answer 183 views
183 views asked Dec 23, 2024 by avibootz
1 answer 205 views
205 views asked Dec 23, 2024 by avibootz
1 answer 182 views
182 views asked Dec 23, 2024 by avibootz
...