Refactor Python Code
Question: I was wondering if anyone could help me refactor the following Python code:

In this example, `endDate` is a string like such: `"2012-08-22"`

    
    
    dateArray = [int(x) for x in endDate.split('-')]
    event.add('dtend', datetime(dateArray[0], dateArray[1], dateArray[2]))
    

I appreciate it!


Answer: 
    from datetime import strptime
    event.add('dtend', strptime(endDate, '%Y-%m-%d')
    

