[英] list in list python
# List
a = []
# Dictionary
b = {}
# Tuple
c = ()
# Set
d = {1,2,3}
list = [132, 31212, 12, 2, 12]
print(list[3])
#output: 2
list = [0,1,2,3,4]
print("printing original list: ");
for i in list:
print(i,end=" ")
list.remove(2)
print("\nprinting the list after the removal of first element...")
for i in list:
print(i,end=" ")
l1 = [1,2,3]
l2 = [4,5,6]
l3 = [7,8,9]
lst = []
lst.append(l1)
lst.append(l2)
lst.append(l3)
print(lst)
class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
import java.util.*;
public class JavaHungry
{
public static void main(String[] args)
{
// Create listOfLists in Java
List<List<Integer>> listOfLists = new ArrayList<>();
// Creating innerList
List<Integer> innerList = new ArrayList<>();
// Adding elements to innerList
innerList.add(1);
innerList.add(2);
innerList.add(3);
// Adding innerList to listOfLists
listOfLists.add(innerList);
// Creating another inner list
List<Integer> innerList2 = new ArrayList<>();
// Adding elements to innerList2
innerList2.add(100);
innerList2.add(101);
innerList2.add(102);
// Adding innerList2 to listOfLists
listOfLists.add(innerList2);
// Printing listOfLists elements
System.out.println(listOfLists);
}
}