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 250 views
3 answers 189 views
189 views asked Apr 24, 2021 by avibootz
1 answer 111 views
1 answer 99 views
99 views asked Dec 23, 2024 by avibootz
1 answer 120 views
120 views asked Dec 23, 2024 by avibootz
1 answer 108 views
108 views asked Dec 23, 2024 by avibootz
...