file = open(r'd:\holiday_list.txt', 'w')
date = ''
while(date != '0'):
date = input('\nEnter Date (YYYYMMDD) : ')
date = date[:4] + '-' + date[4:6] + '-' + date[5:]
file.write(date)
print('Job Done!')
file.close()
This program is supposed to take dates (eg:20112016) as input and write it to a file. The problem is the program does not exit the while loop. If i enter a 0, it prompts me to enter another date.
date = date[:4] + '-' + date[4:6] + '-' + date[5:]modifies the '0' to '0--'.