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 244 views
3 answers 180 views
180 views asked Apr 24, 2021 by avibootz
1 answer 103 views
1 answer 89 views
89 views asked Dec 23, 2024 by avibootz
1 answer 108 views
108 views asked Dec 23, 2024 by avibootz
1 answer 100 views
100 views asked Dec 23, 2024 by avibootz
...