lundi 19 juillet 2021

How to use if else on a non-existant value

The contents of the ScheduledStartDate list is either None or a string. How can I change my codes below to detect and skip the ScheduledStartDate[j] that contains None? And only run the statements when it is not None.

j = 0
while j< len1:
    if (ScheduledStartDate[j] == None):

    else:
        ScheduledStartDate[j] = datetime.datetime.strptime(ScheduledStartDate[j], format)
        
    j=j+1

Aucun commentaire:

Enregistrer un commentaire