Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in Python by (50.2k points)

I am working on the below code:

item = someSortOfSelection()

if item in myList:

    doMySpecialFunction(item)

It will not work with all my items, as if they weren't recognized in the list 

1 Answer

0 votes
by (108k points)

The code that you have provided is absolutely fine and it should operate if the item equals one of the elements inside myList. Either you are trying to obtain a string that is not equal to one of the items or you are using a float value that suffers from inaccuracy. For more information, refer to the Python tutorial.

Related questions

0 votes
1 answer
asked Oct 30, 2020 in Python by Sudhir_1997 (55.6k points)
0 votes
1 answer
asked Oct 11, 2019 in Python by Sammy (47.6k points)
0 votes
1 answer
asked Aug 24, 2019 in Python by Sammy (47.6k points)
0 votes
1 answer
asked Jul 5, 2019 in Python by Sammy (47.6k points)
0 votes
1 answer

Browse Categories

...