I can't figure out how to get only the first item from a list loop.
I am trying to get the first/next calendar item from exchangelib:
My code:
(...)
x = 5000 # minutes in future to look for calendar items
calendar = art(
start=time,
end=time + timedelta (minutes = x),
)
for item in calendar:
print(item.subject)
Output: All the calendar items in this period of time. What do I need to change in the last two lines of code if I want to get only the first/ next item?
Example Output:
First Line
Second Line
Third Line
Wanted Output:
First Line
Edit: Gained some more knowledge in the last few months, i can answer my own question now. And its very simple, I probably wrongly expressed myself and people misunderstood.
Solution:
for item in calendar:
print(item.subject)
break # a simple break so the loop only returns the first result