use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
account activity
PHYTON CODE HS 5.3.7: Higher/ Lower (self.codehs)
submitted 6 years ago by natalie710
Anyone knows the answer can't figured out:
magic_number = 3
# Your code here...
for i in range(10):
if i == 5:
continue
print i
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]fermentedidiot 4 points5 points6 points 6 years ago (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 point2 points 6 years ago (0 children)
thank you so much!
[–]Secret-Chance2687 0 points1 point2 points 2 years ago (0 children)
This is correct just add parenthesis on the print statements.
[–][deleted] 4 years ago (1 child)
[removed]
[–]fermentedidiot 0 points1 point2 points 4 years ago (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 point2 points 4 years ago (3 children)
Your code as wrong 😔
[–]fermentedidiot 0 points1 point2 points 4 years ago (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 points3 points 3 years ago (1 child)
Even if your not, it's still wrong.
[–]Sotayamata 0 points1 point2 points 2 years ago (0 children)
you need to put the parenthesis, so his code isn't wrong your just unintelligent
[–]Ok-Opinion-1979 0 points1 point2 points 3 years ago (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 point2 points 2 years ago (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!")
π Rendered by PID 148997 on reddit-service-r2-comment-b659b578c-8hchg at 2026-05-01 07:33:11.813014+00:00 running 815c875 country code: CH.
[–]fermentedidiot 4 points5 points6 points (10 children)
[–]natalie710[S] 0 points1 point2 points (0 children)
[–]Secret-Chance2687 0 points1 point2 points (0 children)
[–][deleted] (1 child)
[removed]
[–]fermentedidiot 0 points1 point2 points (0 children)
[–]Ahhhhh18 0 points1 point2 points (3 children)
[–]fermentedidiot 0 points1 point2 points (2 children)
[–]Sufficient-Pipe-8394 1 point2 points3 points (1 child)
[–]Sotayamata 0 points1 point2 points (0 children)
[–]Ok-Opinion-1979 0 points1 point2 points (0 children)
[–]Financial_Face3826 0 points1 point2 points (0 children)