質問: [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] and write a program that prints out all the elements of the list that are less than 5. Extras: Instead of printing the elements one by one, make a new list that has all the elements less than 5 from this list in it and print out this new list. Write this in one line of Python. Ask the user for a number and return a list that contains only elements from the original list a that are smaller than that number given by the user. (問題のリンク内容) という問題があり II. コメント欄にはこれでおkというものがありました ``` print([aa for aa in a if aa < 5]) ``` ~以下解説~ What this means is that I'm outputting the variable 'aa' which refers to each item in the list (a). Since 'aa' is set to refer to each item in list (a), the output will print the items in list (a). However, I also have a filter specified at the end of the code "if aa < 5". This means that only the items in the list (referred to as aa) that are below 5 are printed out. It does help if you use labels that are more intuitive in your code. For example instead of naming the list a, I can name the list "number_list": ~終了~ III. ~翻訳~ リストの内包表記は次のように振舞います:[list]の[item]に対する[output] if [filter] ご覧のとおり、その構文には4つのコンポーネントがあります。 出力、アイテム、リスト、およびフィルタ。 上のコードを書いた人の場合[aaに対するaaのaa
回答: https://docs.python.org/3/reference/expressions.html?highlight=comprehension#displays-for-lists-sets-and-dictionaries 例えばこういう解説のことでしょうか。