Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
学ぶ Challenge: Generator Functions | Python Iterators
Pythonにおける関数型プログラミングの概念

bookChallenge: Generator Functions

メニューを表示するにはスワイプしてください

タスク

スワイプしてコーディングを開始

  • Use the yield keyword 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

解答

すべて明確でしたか?

どのように改善できますか?

フィードバックありがとうございます!

セクション 5.  5

AIに質問する

expand

AIに質問する

ChatGPT

何でも質問するか、提案された質問の1つを試してチャットを始めてください

セクション 5.  5
some-alt