Python Word Repeater

Download an eBook today

This code will take a string you enter and repeat it for the number of times you specify using Python.


     * Featured code submitted and Created by Facu.



Python


def repeater(word, cant):
 for i in range(cant):
  print(word)
try:
 a = input()
 b = int(input())
 repeater(a, b)
except (ValueError):
 print("An error ocurred:")
 print("\nThe second value must be a whole number!")
except (EOFError):
 print("An error ocurred:")
 print("\nYou must enter a number in the second line!")




More Free Code Examples:


Python Code to Reverse a String


Hello World in 10 Programming Languages


8 Codes to Find Versions






Comments

Popular posts from this blog

Crypto Mining

Multi-tap Keypad Text Entry