Q:

python - compare user input with list and append to a new list limitng the entry items

I'm learning the python with LPTHW and I'm trying to build own game as exercise 36. I want the user to enter a specific string from the set of 10 disciplines. I can compare the input with defined list, but I can't limit the user to only 5 items. Rather I can restrict the user to only five inputs but not to do both.
I created list of disciplines (originally strings-names
discipline_list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

Then I created an empty list
your_disciplines = []

Here's the code for comparing user input with discipline_list and appending user input to a new empty list (code from other answer).
while True:
    d = raw_input("enter your choice of discipline >> ")
    d = str(d)

    found_d = False
    for i in discipline_list:
        if d == i:
            found_d = True

    if found_d:
        your_disciplines.append(d)
    else:
        print("Incorrect entry")

I can use the for-loop for limiting the user entries, but I can't combine it with comparing. All of my attempts ran more than five times.
for d in range(0, 5):

Any help will be appreciated.

A:

To combine both conditions, check the length of your_disciplines as the while loop condition and only exit when you have 5.
while len(your_disciplines) < 5:
    d = raw_input("enter your choice of discipline >> ")
    d = str(d)

    if d not in your_disciplines:
        your_disciplines.append(d)
    else:
        print("Incorrect entry")

