Your code is using Python’s list comprehension to create a list from another list based on the condition.
See more about list comprehensions here:
https://www.programiz.com/python-programming/list-comprehension
The [1] is accessing the item at index 1 (2nd item) of your sorted list.
As for .join, each line in the sorted list is being printed out with a newline (\n) between each one.
3
solved List comprehension example I don’t understand [closed]