1# Python3 code to demonstrate
2# to get first and last element of list
3# using list indexing
4
5# initializing list
6test_list = [1, 5, 6, 7, 4]
7
8# printing original list
9print ("The original list is : " + str(test_list))
10
11# using list indexing
12# to get first and last element of list
13res = [ test_list[0], test_list[-1] ]
14
15# printing result
16print ("The first and last element of list are : " + str(res))
1Alist = ['Sun','Mon','Tue','Wed','Thu']
2print("The given list : ",Alist)
3
4print("The first element of the list : ",Alist[0])
5print("The last element of the list : ",Alist[-1])