mardi 19 novembre 2019

can anyone help me with this

when i am trying to execute the code, the first if condition is work but the elif condition isn't. After the conditional statements, the except condition is working with no problem.

data = input("Type the number: ")
try:
    integer = int(data)
    decimal = float(data)
    if type(integer) == type(int()):
        for x in range(1,11,1):
            print("{} X {} = {}".format(integer,x,(integer*x)))
    elif type(decimal) == type(float()):  
        for x in range(1,11,1):
            print("{} X {} = {}".format(decimal,x,(decimal*x)))
except (TypeError,ValueError):
    print("Please type a number")

Aucun commentaire:

Enregistrer un commentaire