Как добавить оператор ConcurrentAppointment в мой кодPython

Программы на Python
Anonymous
Как добавить оператор ConcurrentAppointment в мой код

Сообщение Anonymous »

Я создаю программу-дневник встреч. Я не хочу, чтобы встречи пересекались. Как добавить...

Код: Выделить всё

if isConcurrentAppointment(date, startTime, endTime):
print("Concurrent appointment exists. Try again.")
continue
или

Код: Выделить всё

if ConcurrentAppointment(date, startTime, endTime):
print("Concurrent appointment exists. Try again.")
continue
или что-то похожее на приведенный ниже код, чтобы, если введены время начала и время окончания даты встречи, которые перекрывают время начала и окончания другой встречи, он вернет ответ «Существует одновременная встреча». . Попробуйте еще раз."

Код: Выделить всё

def addRecord():
while True:
date = inputDate()
startTime = inputTime("start")
endTime = inputTime("end")
subject = input("Enter an appointment title: ")
schedule.append(appointment)
print("Appointment saved")
Я пробовал этот и другие варианты...

Код: Выделить всё

def addRecord():
while True:
date = inputDate()
startTime = inputTime("start")
endTime = inputTime("end")
if isConcurrentAppointment(date, startTime, endTime):
print("Concurrent appointment exists. Try again.")
continue
subject = input("Enter an appointment title: ")
schedule.append(appointment)
print("Appointment saved")
и

Код: Выделить всё

def addRecord():
while True:
date = inputDate()
startTime = inputTime("start")
endTime = inputTime("end")
if ConcurrentAppointment(date, startTime, endTime):
print("Concurrent appointment exists. Try again.")
continue
subject = input("Enter an appointment title: ")
schedule.append(appointment)
print("Appointment saved")
и программа отвечает...
Синтаксическая ошибка: 'продолжить' неправильно в цикле

Я нашел это в другом посте — можно ли каким-то образом включить его в приведенный выше код, чтобы остановить одновременные встречи?

Код: Выделить всё

    a.start < b.end and a.end > b.start
Если да, то как мне вставить его в код, т. е. если вы можете ответить на этот вопрос, напишите код с включенным выше, чтобы продемонстрировать, как его следует писать.

Подробнее здесь: https://stackoverflow.com/questions/781 ... to-my-code

Вернуться в «Python»