mardi 28 mars 2017

Python IF Statement, straight to ELSE

I seem to have a problem with my script and I hope you guys can help me. I am just beginning with programming so please bear with me. My project is that when somebody fills in any number between 1000-1199 it has to show answer A. If it's any number between 1200-1299 it has to show answer B. But the IF and ELIF statement is not working properly. It skips both of them and goes straight to ELSE.

The script here:

import easygui

var1 = range(1000, 1200)
var2 = range(1200, 1300)

input = easygui.enterbox(msg="Fill in your number", title="Input1")

if input == var1:
    easygui.msgbox(msg="Answer A", title="title1")
elif input == var2:
    easygui.msgbox(msg="Answer B", title="title2")
else:
    easygui.msgbox(msg="Nothing", title="Title3")

Thanks in advance!

Problem solved! Thanks for all the answers.

Aucun commentaire:

Enregistrer un commentaire