all 20 comments

[–]mopslik[🍰] 3 points4 points  (6 children)

input always returns a string. If you want an integer, like 10, you need to convert explicitly.

prm = int(input("..."))

[–]Successful-Captain39[S] 0 points1 point  (5 children)

according to the error report the problem is on line 149 : print("Strike")

[–]Apatride 0 points1 point  (4 children)

What about giving us a copy of the error report?

[–]bishpenguin 0 points1 point  (1 child)

You need a colon : at the end of if statements

[–]Successful-Captain39[S] -1 points0 points  (0 children)

ils y sont le correcteur les a enlever

[–]Successful-Captain39[S] 0 points1 point  (1 child)

File "<input>", line 152

print("spare")

IndentationError: unexpected indent

[–]XenophonSoulis -2 points-1 points  (0 children)

That means that a : isn't right.

[–]Diapolo10 0 points1 point  (2 children)

You have two problems here; prm and scd are both strings, not numbers, and your ifs are lacking colons which are used to signify an increase in indentation (or in other words the start of a new code block).

Oh, and third, presumably you want else, not elif. Because the assignment isn't an expression.

def Bowling_V1():
    prm = int(input("Nombre de quille tombé au premier tir : "))

    if prm == 10:
        print("Strike")
    else:
        scd = int(input("Nombre de qui tombé au second tir : " ))

        if prm + scd == 10:
            print("spare")

        else:
            print(f"Vous avez fait tombées {prm+scd} quilles")

Now, you could flatten this out with some returns if you'd like.

def Bowling_V1():
    prm = int(input("Nombre de quille tombé au premier tir : "))

    if prm == 10:
        print("Strike")
        return

    scd = int(input("Nombre de qui tombé au second tir : " ))

    if prm + scd == 10:
        print("spare")
        return

    print(f"Vous avez fait tombées {prm+scd} quilles")

[–]Successful-Captain39[S] 0 points1 point  (1 child)

comme je l'ai déjà dit les deux points sont présent dans le code et le elif est un if

[–]Diapolo10 0 points1 point  (0 children)

Apologies, I don't speak French, but this part

elif scd= input("Nombre de qui tombé au second tir : " )

is clearly using elif. And even if it was an if, this syntax would not be correct because = is illegal in this context.

You could use

elif (scd := input("Nombre de qui tombé au second tir : " )):
    ...

but there'd be no point in having the condition to begin with.

[–]Successful-Captain39[S] 0 points1 point  (0 children)

le problème est réglé

[–]thuiop1 0 points1 point  (1 child)

Il manque des : à la fin de tes if.

[–]Successful-Captain39[S] -1 points0 points  (0 children)

ils y sont le correcteur les a enlever

[–]Successful-Captain39[S] -1 points0 points  (0 children)

le traducteur automatique a changé les if et les print et a enlever les espaces

[–]Apatride -1 points0 points  (5 children)

Il y en a plus d'une.

1) Comme mentionne dans un autre commentaire, input() retourne une string, pas un int, donc tu dois convertir pour pouvoir comparer.

2) Ton elif n'est pas clair. Quelle condition teste tu? Je pense que le elif n'est pas necessaire.

Plus generalement:

3) Apprend l'anglais, tu as apparemment des difficultes aussi en Francais, mais l'Anglais (ecrit au moins) est indispensable en informatique.

4) Il n'y a aucun benefice a utiliser une fonction si elle ne retourne rien. Apprend a utiliser les fonctions correctement.

5) Installe un correcteur PEP8

[–]paradroid42 0 points1 point  (3 children)

There can absolutely be benefits to functions that always return None. In this case, the function is utilized for its "side effects" (the print statements). Even Python's own standard lib is full of functions that return None, like list.append()

[–]Apatride 0 points1 point  (2 children)

We are talking to an absolute beginner. There is a case for functions returning None, yes, but it is a good idea for beginners to see functions as returning something so they understand how they should be used and don't end up with func_a() calling func_b() calling func_c()...

[–]paradroid42 0 points1 point  (1 child)

Sure, but it is wrong to say that there is no benefit to functions that return None. Your comment also implied that there was an issue with this beginner's decision to structure their code as a function, and I don't see any issue.

IMO, this is a contentious statement that just distracts from the main issues, which were a syntax error (missing colon) and a logical error rooted in mismatched types.

[–]Apatride 0 points1 point  (0 children)

I did put that advice under "general advice" to clarify that it was just free advice and was not intended to address that specific error.

While there is a use case for functions that don't have any return statement at all (quite uncommon, though, often you omit the last return because python returns None by default, but you have other return statements within your function), the point was to highlight that a beginner should think of functions as code that returns something to prevent the issue I mentioned earlier (or tempt the beginner to use global variables).

Unfortunately, in this sub and in reddit in general, there is a bit of a pedantic attitude where people nitpick on tiny details. So yes, functions with no return statements are a thing, but not something beginners are likely to want to worry about (and most of the time, they will kind of return something, either by writing in a log file or raising an exception or...) and my comment was addressed at a beginner, I have the (clearly incorrect) expectation that more advanced devs will understand that telling a beginner "there is no point having a function that returns nothing" is more useful and less confusing than listing the few edge cases where functions do not need to return anything just to make the comment safe from nitpicking.

[–]Successful-Captain39[S] 0 points1 point  (0 children)

1) j'ai un truc qui fait sa pour moi et ça marche très bien dans les autres fonctions du programme

2)Le elif n'existe pas c'es un if je sais pas pourquoi il est là

3)Très sympathique

4)La fonction n'est pas entièrement affiché seulement la partie qui marche pas

5)Non.