In the code block below, I understand that s is the string. re.split() will generate a list of split results and the list comprehension will iterate through every result created.
I don't understand how "if i" will work here.
This is from the following stackoverflow thread: https://stackoverflow.com/a/28290501/11292262
s = '125km'
>>> [i for i in re.split(r'([A-Za-z]+)', s) if i]
['125', 'km']
>>> [i for i in re.split(r'(\d+)', s) if i]
['125', 'km']