Python Forum

Full Version: coding idea
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
here is how i form plurals in f-strings. if you are using a version of Python before 3.6 you can rearrange the code to something that works there.
    if unknown_options:
        num = len(unknown_options)
        msg = f'there {("are","is")[num==1]} {num} unknown option{"s"[num==1:]}'
        raise ValueError(msg)
i don't know if there are any issues with this so i will post it here in the bar to see if i get a reaction about it.
inflect is very interesting. no more excuses for bad number grammar on websites in Python.