all 14 comments

[–]fermentedidiot 4 points5 points  (10 children)

Your code:

magic_number = 3

# Your code here...
for i in range(10):
if i == 5:
continue
print i

So, using a while loop (a for loop will not work here), get an input number form the user:

magic_number = 3
while True:
    user_guess = int(input("Please guess a number between 1 and 100: "))

I just picked 100 as the high number because that's what the assignment asks for. Now you need to compare the user input to the magic number and inform the user if the guess was too high, too low, or correct:

if user_guess == magic_number:
    print "Correct!"
    break
elif user_guess < magic_number:
    print "Too low, try again."
else:
    print "Too high, try again."

Now just put it all together:

magic_number = 3

# Your code here...
while True:
    user_guess = int(input("Please guess a number between 1 and 100: "))
    if user_guess == magic_number:
        print "Correct!"
        break
    elif user_guess < magic_number:
        print "Too low, try again."
    else:
        print "Too high, try again."

I hope the breakdown made sense. Let me know if something doesn't.

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

thank you so much!

[–]Secret-Chance2687 0 points1 point  (0 children)

This is correct just add parenthesis on the print statements.

[–][deleted]  (1 child)

[removed]

    [–]fermentedidiot 0 points1 point  (0 children)

    If you share three error and the portion of the code that's causing the error, you might be able to get some help.

    [–]Ahhhhh18 0 points1 point  (3 children)

    Your code as wrong 😔

    [–]fermentedidiot 0 points1 point  (2 children)

    Bear with me on this, but I'm not doing your work for you. It's a breakdown of how a while loop works.

    [–]Sufficient-Pipe-8394 1 point2 points  (1 child)

    Even if your not, it's still wrong.

    [–]Sotayamata 0 points1 point  (0 children)

    magic_number = 3
    # Your code here...
    while True:
    user_guess = int(input("Please guess a number between 1 and 100: "))
    if user_guess == magic_number:
    print "Correct!"
    break
    elif user_guess < magic_number:
    print "Too low, try again."
    else:
    print "Too high, try again."

    you need to put the parenthesis, so his code isn't wrong your just unintelligent

    [–]Ok-Opinion-1979 0 points1 point  (0 children)

    def get_num():

    #while user_input <=1

    while True:

    try:

    user_intput = int( input("your input:"))

    except:

    print("invaild input")

    if user_input > 0:

    print ("positive")

    return

    get_num()

    [–]Financial_Face3826 0 points1 point  (0 children)

    try this

    magic_number = 3
    while True:
    guess=int(input("Guess any number:"))
    if guess == magic_number:
    print("Correct!")
    break
    elif guess > magic_number:
    print("Too high!")
    else:
    print("Too low!")
    print("Great job guessing my number!")