Challenge: Generator Functions
Veeg om het menu te tonen
Taak
Veeg om te beginnen met coderen
- Use the
yieldkeyword to return each log line one by one as the function iterates through the list. - Do not create or return a new list, yield each line directly from the input list.
- The function should be memory efficient and work with any length of input list.
- Test your function by iterating over
read_log_lines(log_lines)and printing each line. - Expected results:
2024-06-01 12:00:01 INFO User logged in
2024-06-01 12:00:03 ERROR Invalid password attempt
2024-06-01 12:00:05 INFO User logged out
2024-06-01 12:00:07 WARN Disk space low
2024-06-01 12:00:10 INFO User logged in
Oplossing
Was alles duidelijk?
Bedankt voor je feedback!
Sectie 5. Hoofdstuk 5
Vraag AI
Vraag AI
Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.
Sectie 5. Hoofdstuk 5