I need to write a program in which user is asked: to select 1 (and only 1) team amongst 3 teams and to select 1 or several products amongst a longer product list.
My code works fine with 1 product only.
Any hint? (I found this useful post related, but not really documented on multiple selection)
Here is my program (Python 3.7)
from itertools import chain, repeat # User select 1 team, uppercase teams = {'OTEAM', 'ZTEAM', 'DREAMTEAM'} prompts = chain(["Enter 1 team: "], repeat("No such team? Try again: ")) replies = map(input, prompts) valid_response = next(filter(teams.__contains__, replies)) # Show team selected print(f"you want to configure {valid_response}") # User select 1 or several product, products = {'Aprod', 'Bprod', 'Cprod'} prompts_prod = chain(["Enter product(s): "], repeat("No such product, try again: ")) replies_prod = map(input, prompts_prod) valid_response_prod = next(filter(products.__contains__, replies_prod)) print(f"---Result --- \nin {valid_response} you want to configure \n{valid_response_prod}")