While loop not working

code is not working …any one pls help me what is wrong ???
isCorrectDate = False
while (isCorrectDate == False):
try:
newDate = datetime.datetime(syear,smonth,nday)
isCorrectDate = True
except ValueError:
smonth = smonth + 1
if smonth > 12:
smonth = 12
syear = syear + 1
isCorrectDate = False

Hard to parse your code without proper indentation. Maybe post a screenshot
Can you explain what you are trying to do?

I want to check date is valid(exist) or not
if not valid than check same day in next month
eg. 31-02-2017 is not valid than check for next month