Strings and Arrays/Lists. Please help!

Write a program that continuously prompts for a string to be entered from the keyboard until one of "y", "yes", "oui", "n", "no", or "non" (in lower or upper case) is entered, then outputs "You entered 'yes'" or "You entered 'no'", as appropriate.

Use an array containing each of the test cases, as follows:

yesNo = ["y", "yes", "oui", "n", "no", "non"]

The program should loop through each of the test cases to determine if one of those cases was chosen.

If I thought your code wouldn't work I'd have used the site reputation feature.

As for "all programmers/coders have their own ways of doing their jobs", choosing among various algorithms for the same task distinguishes programmers.

red-black tree runs in O(log(n)) time, while the list search runs in O(n).

OK, for short lists or for just a single look up if you already have a list but not a set the list search is faster. The set search for 100 thousand elements is ten thousand times faster than list search. If I have to create the entire set anew (corresponds to a single look up) then the set search is 10 times slower than list search. For a list length 8 similar to this thread the list search is faster. Twice as fast.

Code:

>>> import timeit
>>> timeit.timeit('L[len(L)//2] in L',setup='import random;L=[random.random()for i in range(99999)]',number=100)
0.14156699180603027
>>> timeit.timeit('L[len(L)//2] in S',setup='import random;L=[random.random()for i in range(99999)];S=set(L)',number=100)
3.218650817871094e-05
>>> timeit.timeit('L[len(L)//2] in S',setup='import random;L=[random.random()for i in range(99999)];S=set(L)',number=100)
2.9087066650390625e-05
>>> timeit.timeit('L[len(L)//2] in L',setup='import random;L=[random.random()for i in range(99999)]',number=100)
0.23739981651306152
>>> timeit.timeit('L[len(L)//2] in L',setup='import random;L=[random.random()for i in range(8)]',number=100)
3.314018249511719e-05
>>> timeit.timeit('L[len(L)//2] in S',setup='import random;L=[random.random()for i in range(8)];S=set(L)',number=100)
6.318092346191406e-05
>>> timeit.timeit('S=set(L);L[len(L)//2] in S',setup='import random;L=[random.random()for i in range(99999)]',number=100)
2.93165922164917
>>>