I was making a simple code block involving random.randrange but there's an infuriating issue I can't seem to fix.
import random
r = random.randrange(0, 1)
x = input("Pick a number from 0 to 1. ")
if r == x:
print("Contragulations! You guessed it right.")
elif r != x:
print("Oops! You got it wrong. ")
It always pops up as me being wrong, no matter what. I thought it was just bad luck but after 3000 tries, now it just has to be some kind of issue with the code. It works, there's no error but not as intended. Just an "Oops! You got it wrong." machine. Help?
I reviewed the code and I don't see anything wrong despite there being something wrong.
Make a piece of code that involves guessing a random number.
What actually happened was an "Oops! You got it wrong." machine in which it's basically impossible to get it right.