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 360 views
3 answers 318 views
318 views asked Apr 24, 2021 by avibootz
1 answer 192 views
1 answer 177 views
177 views asked Dec 23, 2024 by avibootz
1 answer 199 views
199 views asked Dec 23, 2024 by avibootz
1 answer 177 views
177 views asked Dec 23, 2024 by avibootz
...