So i have a basic question: how to use if and else statements correctly with easyGUI? This is what I have:
import easygui
msg = "Oh i see m9, choos your difficulty"
title = "Mountain Dew Franchise"
choices = ["Pro 360 noscoper(+1001)", "Dank skrubl0rd(-666)"]
choice = easygui.ynbox(msg, title, choices)
#if choices==choices[0]:
easygui.msgbox("Good choos m20, let the skrubl0rd noscoping begin.")
#if choices==choices[1]:
easygui.msgbox("Oh i see m8.")
The # lines seem to be the problem area
It does not let me go to either msgbox, but instead just closes the program, any help would be appreciated.
choice = easygui.ynbox(msg, title, choices)
This ynbox returns True
or False
. That means that choice
can only be one of these two values.
if choices==choices[0]:
You are comparing if your list (choices
) is equal to the value of your first element in the same list.
To make your program work, you need to modify your if
section a bit.
if choice:
easygui.msgbox("Good choos m20, let the skrubl0rd noscoping begin.")
else:
easygui.msgbox("Oh i see m8.")
Since choice
can only be True
or False
and the first option in your choices
list become the True
value, this logic will work.