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 322 views
322 views asked Apr 24, 2021 by avibootz
1 answer 197 views
1 answer 182 views
182 views asked Dec 23, 2024 by avibootz
1 answer 203 views
203 views asked Dec 23, 2024 by avibootz
1 answer 181 views
181 views asked Dec 23, 2024 by avibootz
...