now this is the source. Someone please help me how to deal with this
for k in range(no_of_resc):
name_resch = input('enter then name of the patient you want to reschedule : ')
date_resc = input('enter the date you want to reschedule : ')
date_for_resc = datetime.datetime.strptime(date_resc, '%Y-%m-%d %H:%M:%s')
print('the appointment is rescheduled for ',name_resch,'and on',date_for_resc)
resch_pat.append(name_resch)
print('the appointment is rescheduled for :' , resch_pat)
now now this is the output So here i have 6options (forget about those option) when i enter the date i want to get appointment im getting this error something like ValueError
1 . register no.of doctors
2 . register no.of patients
3 . do you want to book appointments ?
4 . reschedule the appointments ?
5 . cancel the appointments.
6 . Exit
enter your selection : 3
enter the number of doc : 1
enter number of patient : 1
>>
enter the name of the doctor : knan
is the doctor free? (y/n) : y
[]
['y ']
enter the name of the patient : ganesh
['ganesh ']
lol
enter the date you want to get appointed (yyyy-mm-dd hh:mm): 2023-10-9 8:31:31
Traceback (most recent call last):
File "c:\Desktop\vsc\JavaScript\05-Guess-My-Number\starter\doctor.py", line 51, in <module>
date = datetime.datetime.strptime(appnt_date,'%Y-%m-%d %H:%M')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\_strptime.py", line 568, in _strptime_datetime
tt, fraction, gmtoff_fraction = _strptime(data_string, format)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\_strptime.py", line 352, in _strptime
raise ValueError("unconverted data remains: %s" %
ValueError: unconverted data remains: :31
CodePudding user response:
In this line, you enter the date with seconds:
enter the date you want to get appointed (yyyy-mm-dd hh:mm): 2023-10-9 8:31:31
But the conversion is not correct with this pattern, you have here (c:\Desktop\vsc\JavaScript\05-Guess-My-Number\starter\doctor.py):
date = datetime.datetime.strptime(appnt_date,'%Y-%m-%d %H:%M')
The conversion should be:
date = datetime.datetime.strptime(appnt_date,'%Y-%m-%d %H:%M:%s')