diff --git a/questionary/prompts/select.py b/questionary/prompts/select.py index d6d41c5d..a9443061 100644 --- a/questionary/prompts/select.py +++ b/questionary/prompts/select.py @@ -132,14 +132,16 @@ def select( if choices is None or len(choices) == 0: raise ValueError("A list of choices needs to be provided.") - if use_shortcuts and len(choices) > len(InquirerControl.SHORTCUT_KEYS): - raise ValueError( - "A list with shortcuts supports a maximum of {} " - "choices as this is the maximum number " - "of keyboard shortcuts that are available. You" - "provided {} choices!" - "".format(len(InquirerControl.SHORTCUT_KEYS), len(choices)) - ) + if use_shortcuts: + real_len_of_choices = sum(1 for c in choices if not isinstance(c, Separator)) + if real_len_of_choices > len(InquirerControl.SHORTCUT_KEYS): + raise ValueError( + "A list with shortcuts supports a maximum of {} " + "choices as this is the maximum number " + "of keyboard shortcuts that are available. You " + "provided {} choices!" + "".format(len(InquirerControl.SHORTCUT_KEYS), real_len_of_choices) + ) merged_style = merge_styles_default([style])