I want to check if The input is 'str' or it's 'int' and if it's 'str' repeat the loop...
but i don't know how to check if the input was for example: dds
but i don't know how to check if the input was for example: dds
while True: rows_input = input("Enter Rows: " ) cols_input = input("Enter Cols: " ) if int(rows_input) and int(cols_input): #here i'm trying to check it but i get error # i want to check if it's possible to convert the str to int then close the loop but i can't break else: print("you have to Enter a Number not string... [Try again]")
# Here are inputs >>> Enter Rows: dds >>> Enter Cols: 2
Error:Traceback (most recent call last):
File "Matrix_Calculator.py", line 5, in <module>
if int(rows_input) and int(cols_input): #here i'm trying to check it but i get error
ValueError: invalid literal for int() with base 10: 'dds'
but if the inputs be int, there's no problem and no error and the loop ends>>> Enter Rows: 2 >>> Enter Cols: 2
Error:No Error