저는 파이썬으로 약속 캘린더 응용 프로그램을 만들고 첫 번째 부분과 고민하고 있습니다.빈 사전에 약속을 추가해야합니다.
저는 약속이라고 불리는 빈 사전과 임명을 추가하려고합니다. 그 작동하지만, 어떤 이유로 자신이 약속을 축적하지 :
appointments = {}
while (True):
(... I had a choice variable here that would ask the user to either make an appointment, cancel, or view list of appointments. but for right now, i am only focusing on making appointments.)
elif choice == 1: #Making an appointment
apptDate = input('Enter date (mm/dd/yy)\n')
apptTime = input('Enter time (hh:mm)\n')
apptDesc = input('Enter a brief description of the appointment\n')
#Checking to see if key in dictionary
if apptDate not in appointments:
newAppt = apptTime + '\t' + apptDesc
appointments[apptDate] = newAppt
else:
appointments[apptDate] = newAppt
내가 약속에 apptTime + '\ t'+ apptDesc을 배치 할 필요는 키로 apptDate를 사용하여 사전. 나는 내가 옳은 일을한다고 생각했다.
apptDate가 새 약속을 추가하는 방식에 영향을주기 때문에 apptDate가 이미 약속 사전에 있는지 확인하십시오. 어떤 도움이 좋을 것
아마도 버그가 있습니다. '약속 [apptDate]'를 체크하면 같은 날짜에 다른 시간에 약속을 가질 수 있다는 것을 무시하고 있습니다. – Santiago