In this code, we will see how to print a string 3 times in Python
Using just print() function
str = "Hello World "
print(str * 3)
#Hello World Hello World Hello World
Using for loop:
str = "Hello World"
for i in range(3):
print(str)
#Hello World
#Hello World
#Hello World
Using while loop:
str = "Hello World"
i = 1
while(i<4):
print(str)
i = i + 1
#Hello World
#Hello World
#Hello World