Or shorten David’s answer with:
if 4 <= day <= 20 or 24 <= day <= 30:
suffix = "th"
else:
suffix = ["st", "nd", "rd"][day % 10 - 1]
More Related Contents:
- How to remove items from a list while iterating?
- Python subprocess readlines() hangs
- Text progress bar in terminal with block characters [closed]
- How do I check what version of Python is running my script?
- “ssl module in Python is not available” when installing package with pip3
- Writing Unicode text to a text file?
- What does the percentage sign mean in Python
- pandas dataframe str.contains() AND operation
- Does spark predicate pushdown work with JDBC?
- Concatenate Numpy arrays without copying
- How to insert a character after every 2 characters in a string
- How to simulate Jumping in Pygame for this particular code
- Bin size in Matplotlib (Histogram)
- How can I check whether a numpy array is empty or not?
- Numpy Resize/Rescale Image
- How do I detect if Python is running as a 64-bit application? [duplicate]
- Run local python script on remote server
- JSON serialize a dictionary with tuples as key
- is there a way to loop over two lists simultaneously in django?
- How do I run graphx with Python / pyspark?
- Python script to list users and groups
- Using asyncio.Queue for producer-consumer flow
- What’s the best solution for OpenID with Django? [closed]
- Where are the python modules stored?
- How to delete all the entries from google datastore?
- OneHotEncoder categorical_features deprecated, how to transform specific column
- SQLAlchemy classes across files
- How to pad a string to a fixed length with spaces [duplicate]
- How to properly use the “choices” field option in Django
- Get Element value with minidom with Python