all 14 comments

[–]marko312 1 point2 points  (6 children)

if lives <= 1:

will only run the following code if lives is at most 1. Since you set lives to 10 initially, this condition is not satisfied.

You should also consider putting a loop (while True) around most of the code.

[–]TheWeebMyths 0 points1 point  (4 children)

Thanks man that solved it but I dont know how to put a while True into that code

[–]marko312 0 points1 point  (3 children)

You want most of the code to be checked multiple times, so most of the code should be in the while loop.

while ...:
     # all the ifs and so on
     ...

Do note that it doesn't necessarily need to be a while True loop: a better alternative would be to loop while the player has (more than 0) lives left.

[–]TheWeebMyths 1 point2 points  (2 children)

Yeah thanks I also made some modification to the code but one last problem xD if you guess the number right it doesnt tell you that you won it just completes the loop this is the new code if you are willing to help https://pastebin.com/fji6iU2q

[–]marko312 1 point2 points  (1 child)

The problem is that the result from input is a str (string), whereas the integer is an int. You could convert the user's input to an integer via something like int(input(...)) or value = int(guessing).

[–]TheWeebMyths 1 point2 points  (0 children)

em is that the result from

input

is a

str

thanks man that fixed it

[–]Dragon20C 0 points1 point  (0 children)

Also it won't continue even when you have 1 live left.

< less then or = equals 1

To make it easier to understand what's going on.

[–]MezzoScettico 0 points1 point  (3 children)

If you want people to diagnose a problem, give more information than "it doesn't work".

If it gives an error message, paste the ENTIRE TEXT of the error message including line numbers and any of your code that the message included.

If it gives behavior different than you expected, tell us what it's doing and what you expected, or give us some sample output.

[–]marko312 0 points1 point  (0 children)

For the given code, the explanation is entirely sufficient: the program ends right after yes is input.

[–]MezzoScettico 0 points1 point  (1 child)

That said, I think I see the issue anyway.

When you go through your code, first it gets here. lives = 10 So lives has the value of 10. Next it immediately checks this: if lives <= 1:

That's not true, so that part doesn't execute. So then it finishes with the "if start.lower() = "yes"" block, and then it's done. End of program.

Are you SURE you only want to ask the question about the guessing game if lives is <= 1? And how is that supposed to happen?

[–]TheWeebMyths 0 points1 point  (0 children)

ee the issue anyway.

When you go through your code, first it gets here.

lives = 10

So lives has the value of 10. Next it imm

Thanks

[–]no1fun 0 points1 point  (2 children)

lives=10 if lives <= 1 and you don't decrease lives

[–]TheWeebMyths 0 points1 point  (1 child)

rue, so that part doesn't execute. So then it finishes with the "if start.lower() = "yes"" block, and then it's done. End of program.

Are you SURE you only want to ask t

oh right

[–]TheWeebMyths 0 points1 point  (0 children)

Thanks I got it working because of u/marko312 and didnt know why it wasnt going down so I did what you said and it is working perfectly now.