Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Comparing any values. from a list to what puts in the entry box in tkinter

i want to to take information using entry widget and to compare and see if the input
in the entry box equals to one or more strings that i store inside a list
i tried :

if Entry.get() == any MyList[]:
          Mylable.pack()

also:

if Entry.get() == MyList[0:10]:
          MyLable.pack()

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can use the in operator, which can check if a value is present anywhere inside of a list:

if Entry.get() in MyList:
    Mylable.pack()

Or if you want to check to see if the entry text is in the first 10 elements of MyList:

if Entry.get() in MyList[0:10]:
    MyLable.pack()
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading