I made this try to answer Q3 but it doesn't work as the solution what's wrong here?
num1 = input("Please enter a number between 1 and 12 inclusive \n >>")
if num1.isdigit():
num1 = int(num1)
if 12 >= num1 >= 1:
for i in range(1,13):
print(f"{num1} times table")
print(f"{i} * {num1} = {i * num1} ")
else:print("your entered number is outside range, try again")
num1 = input("Please enter a number between 1 and 12 inclusive \n >>")
else: print(" your input is not even a number, try again")
num1 = input("Please enter a number between 1 and 12 inclusive \n >>")
Hey Hosam,
Thank you for reaching out!
This problem cannot be solved using if
-statements. You should instead use while
-loops, as demonstrated in the lecture.
Kind regards,
365 Hristina
Hey! Hosam,
There is one clarification of your structure. first of all, the task given in question 3 is conditional base and implementation of For Loop at start point is inappropriate.
For Loop work on provided range. More specifically, it runs as much times you want to execute Loop block and it doesn't check conditions. This means, once the loop Start execute it wouldn't stop till the given range
and on start, if user put an incorrect value or string then the loop will execute only else statement and exit. If user will enter's a correction then for loop will execute but input statement indention is in correct. also if the indentation is correction and your table will occurred but it doesn't statisfy the question.