Hey just starting to learn python and got some problems already I made a code with an if statement It should work but it isn\'t working can someone fix it and tell me what I did
You have to convert the input to an integer by putting it in int:
x= raw_input("Enter your name: ")
################
y= int(raw_input("Enter your grade: "))
################
print(y)
if y>=50 and y<=100:
print("Good input")
else:
print ("Invaild input")
Remember that raw_input
always returns a string. So, in your if-statement, you are comparing a string with integers. That is why it doesn't work.
Actually, whenever I need to print one message or another, I like to put it on one line (unless of course the messages are long):
print("Good input" if 50 <= y <= 100 else "Invaild input")
Making a whole if-else block seems a little overkill here.