The code below works with the number but will not work when I add a dash to the input and I don't know how to make it accept that.
I think the exception works but I don't know if it works properly because I want to error if its a letter.
My question is how do I make it accept the dash with the number in the input and check if the user has put in a letter instead of a number.
def main(day_number,month_number,month_name,date_,month_list,date_1,year,fulldate):
day_number = 0
month_number = 0
month_name = ''
date_ = ''
month_list = ['January','February','March',
'April','May','June','July',
'August','September','October',
'November','December']
date_ = input("Enter a date in the format mm/dd/yyyy: ")
while True:
try:
float(date_)
date_1= date_.split('/')
month_number = (date_1[0])
day_number = date_1[1]
year = date_1[2]
month_name = month_list[month_number - 0]
fulldate = month_name + ' ' + day_number + ',' + year + '.'
print(fulldate)
break
except ValueError:
print("""ops it's not a number, please try again""")
date_ = input("Enter a date in the format mm/dd/yyyy: ")
break
main("day_number","month_number","month_name","date_","month_list","date_1","year","fulldate")