for i in range(n):
    &n" /> Write a Python program to get a string which is n (non-negative integer) copies of a given str   for i in range(n):
    &n" />
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:
M
Mr. Dubey     View Profile
Founder of MCQ Buddy. I just like to help others. This portal helps students in getting study material free. Share your stuff here so that others can get benefitted.