You are here: Home / Topics / Write a Python program to get a string which is n (non-negative integer) copies of a given str

Write a Python program to get a string which is n (non-negative integer) copies of a given str

Filed under: Python on 2023-09-23 06:50:40

def larger_string(str, n):
  result = ""
  for i in range(n):
     result = result + str
  return result

print(larger_string('abc', 2))
print(larger_string('.py', 3))     

Output:

abcabc                                                                                                        
.py.py.py  

About Author:
S
Shyam Dubey     View Profile
If you are good in any field. Just share your knowledge with others.