Way to create a new list from iterable by transforming the items . Syntax: [ output_expression for item in iterable [ conditions ] ] numbers = [1, 2, 3, 4, 5, 6] squares = [number**2 for number in numbers] print(squares) #Output: [1, 4, 9, 16, 25, 36] Using if condition We can use if condition to filter out some elements. numbers = [1, 2, 3, 4, 5, 6] squares = [number**2 for number in numbers if number > 2] print(squares) #Output: [9, 16, 25, 36] Using multiple if condition (ANDing) We can use multiple if conditions to filter out elements. All if conditions will be ANDed numbers = [1, 2, 3, 4, 5, 18, 30] list_1 = [number for number in numbers if number % 2 == 0 if number % 3 == 0] print(list_1) #Output: [18, 30] Using ‘in’ statement (ORing) 'in' keyword can be used to create a condition statement. numbers = [1, 2, 3, 4, 5, 18, 30] list_2 = [number for number in numbers if number % 3 in (1, 2)] print(list_2) #Output: [1, 2, 4, 5] ...
In computer science, a linked list is a linear collection of elements, called nodes, each node have info field and next field pointing to the next node by means of a pointer. It is a data structure consisting of a group of nodes in sequence and connected with links. In simplest form of this data structure, each node is consist of data and a reference (in other words, a link) to the next node in the sequence. This structure allows for efficient insertion or removal of elements from any position in the sequence during iteration. Types of Link List Singly Link List: Insert node at first position in singly link list Insert node at last position in singly link list Insert node at specific position in singly link list Delete node at first position in singly link list Delete node at last position in singly link list Delete node at specific position in singly link list Find number of nodes in singly link list Dublication of singly link list Concatenation of two singly link list So...