Checking type

Hi. I want to be sure the entery for "repeat" is integer. And i want use a condition like IF or ... to make a warning when the "type of repeat" is not ineger. (Sorry for my bad English 😶) https://code.sololearn.com/c8UNLJfoCZXl/?ref=app

4/16/2019 6:47:20 AM

Pendar Alipour

5 Answers

New Answer


Do this: if(repeat.isdigit()): print(mystr * int(repeat)) else: print("It's not a number !!!") Don't forget to convert the string with numbers to a number with int(str)


You're welcome


As an alternative to Javier Felipe Toribio's solution, you can use a try-except block like: try: print(mystr * int(repeat)) except: print("Is not a number") Its much easier and is does what it was designed to do😉🐍☕



Tnx javier. I like it.