Question: I have two columns startDate and endDate
I need to calculate number of hours count from 0 to 23 between these dates
Example, start date is 2000-12-05 10:00:00 and end date is 2001-01-15 15:00:00
I need to calculate how many times hour 0 to 23 occurred between these two dates in python

I took the difference between the dates and calculated hours from the difference.
After which I plan to extract start hour from startDate till startDateHour \* hours to get the endHour
and iterate through a dictionary to increase the count, but is there any other approach with which I can do this?

```
df['diff'] = df['endDate'] - df['startDate']
df['hours']= df['diff'] / np.timedelta64(1, 'h')

```

Answer: 
You can turn your expression into a regex and try matching with that:

```
import re

words = [
    'Apple',
    'Christmas Tree',
    'Shopping Bag'
]

match = '???i???as ?r??'
regex = '^' + match.replace('?', '.') + '$'  # turn your expression into a proper regex

for word in words:    # go through each word
    if re.match(regex, word):   # does the word match the regex?
        print(word)

```

Output:

```
Christmas Tree

```
Try If `str` is in list.

```
IF "str" IN [list]

```