简体   繁体   中英

TypeError: unsupported operand type(s) for *: 'function' and 'int'

def projet_catapulte(point_de_vie_1, point_de_vie_2) :
    """ Jeu de catapulte joueur1 vs joueur2 tour à tour  """
    assert isinstance(point_de_vie_1, (int)), "Type a incorrect, il faut un int "    # controle des types
    assert isinstance(point_de_vie_2, (int)), "Type b incorrect, il faut un int"    # des arguments 

    #var
    point_d_impact=0.0   #float
    temps=0.0            #float
    i=0                  #int
    j=1                  #int
    angle=0.0            #float
    #begin
    point_de_vie_1=20
    point_de_vie_2=20
    while point_de_vie_1 > 0 or point_de_vie_2 > 0 :
        #begin
        i=1
        while i > 0 :
            #begin
            print("joueur_1 joue")
            angle=int(input("Entrez l'angle : "))
            temps=(temps_appuie)
            point_d_impact=((temps*angle)/38)
            print(point_d_impact)

Really don't know this typeError

temps_appuie is a function, and you've put a reference to it into temps . Perhaps you meant to call it instead.

temps=(temps_appuie)

You are making temps to point to a function. So, in this statement

point_d_impact=((temps*angle)/38)

you are multiplying a function with angle which is a number. Thats why it fails. Did you mean to call the function like this?

temps=temps_appuie()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM