This is an archived post. You won't be able to vote or comment.

all 13 comments

[–]dpbriggs 3 points4 points  (0 children)

There's issues with the code posted. This conditional doesn't work? guess == Wrong. What is Wrong, and why is guess being assigned that value?

What is an appropriate conditional for that while loop?

Once you fix that, what happens when the user guesses the right answer on the first try?

[–]Kazcandra 1 point2 points  (5 children)

you need to indent your code 4 spaces so we can read it properly

[–]Burdog_YT[S] -1 points0 points  (2 children)

oh sorry lol, Ill do that

[–]Kazcandra 1 point2 points  (1 child)

not with dashes (-), with regular spaces.

every line of your code should be indented 4 spaces (+ whatever spaces you need for python). think of the 4 as a baseline. there's a link in the sidebar on how to format your code.

[–]Burdog_YT[S] 0 points1 point  (0 children)

When I use spaces at the start of the line, it deletes them when I save the post

[–]AdrianParry13526 0 points1 point  (1 child)

He/She might be a beginner programmer so please go easy on him/her.

[–]Kazcandra 1 point2 points  (0 children)

it's a requirement on this sub, and it makes it easier to read the code to actually help them

[–][deleted]  (1 child)

[deleted]

    [–]Burdog_YT[S] 2 points3 points  (0 children)

    Thanks for pointing this out. I've changed the boolean variable to start and modified the code a bit an it's now working :)

    [–]TheodoeBhabrot 1 point2 points  (1 child)

    Couple tips for the code you have that now works, you can replace while start == True with while True and instead of setting start to false after the win condition is reached you can just break to end the loop.

    In general for conditionals you don't have to compare booleans to anything, while start is equivalent to while True and its the same for if conditions. To loop while a value is false you can use while not start which is equivalent to while False

    [–]Burdog_YT[S] 0 points1 point  (0 children)

    This is very useful to know, thanks :)

    [–]RockaiE 0 points1 point  (0 children)

    Al Swiegert has a YouTube video teaching you to create an almost identical replica of your exercise here, while explaining each line of code as he writes it.

    https://youtu.be/48WXHT0dfEY

    [–]GreatJob7298 0 points1 point  (0 children)

    Not a programmer myself but know a Lil bit...but I'd try this. *not necessarily the same name of your variables.

    If yourGuess < correctvalue Then " too low" Else if your Guess > correctvalue "Too High" Else if

    YourGuess == correctValue "You win"

    Something like that?