I'm asking you a question about the end of the repeat. I want to end the repetition by typing F...

Asked 2 years ago, Updated 2 years ago, 17 views

while True:
    def calc_GUGUDAN(dan):
        for i in range(1, 10):
            print (input_data, "X", i, "=", input_data*i)
    input_data=int (input ("enter")


    if input_data>=1 and input_data<=9:
        calc_GUGUDAN(input_data)
    else:
        print("Calculate only numbers from 1 to 9."")

It's a program that runs multiplication tables by receiving one of the numbers from 1 to 9, and I want to end the repetition by typing F, how can I do it?

python

2022-09-20 22:14

1 Answers

If you enter F in int(input(".."), an error will occur. Therefore, you can divide the conversion into two processes: input and int.

input_str=input("Enter a stage")
## Check if input_str is 'F' and exit.
input_data = int(input_str)


2022-09-20 22:14

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.