Doubt in python lists

Hello, @pravar.

Please format your code for proper display when you post it. See the Python Discourse Quick Start page for advice regarding how to post code snippets, error messages, etc. As explained there, you can place your code between two lines of triple backticks to format it.

The second line of your code contains a list comprehension that loops though the items in the words list. For each item that contains more than five characters, it creates a tuple that contains the first and the last character within that item. In the list comprehension, (word[0], word[-1]) represents that tuple. Note the two subscripts within the square brackets, namely 0 and -1. The first of those two accesses the character at index 0 in the item from the words list, and the second of those two subscripts, -1, accesses the final character in that item. When running the program, you should see the following output:

[('E', 'n'), ('S', 'a')]

For official documentation about list comprehensions, see 5.1.3. List Comprehensions.