import itertools
a=[[1, 2, 3], [4, 5, 6]]
flat_list = list(itertools.chain.from_iterable(a))
print(flat_list)
# Output:
[1, 2, 3, 4, 5, 6]
# example of a nested list
my_list = [[1, 2], ["one", "two"]]
# accessing a nested list
my_list[1][0] # outputs "one"
L = [[1, 2, 3],[4, 5, 6],[7, 8, 9]]
for list in L:
for number in list:
print(number, end=' ')
# Prints 1 2 3 4 5 6 7 8 9
>>> from collections import Iterable
def flatten(lis):
for item in lis:
if isinstance(item, Iterable) and not isinstance(item, str):
for x in flatten(item):
yield x
else:
yield item
>>> lis = [1,[2,2,2],4]
>>> list(flatten(lis))
[1, 2, 2, 2, 4]
>>> list(flatten([[1, 2, 3], [4, 5, 6], [7, 8, 9]]))
[1, 2, 3, 4, 5, 6, 7, 8, 9]
x = [3, 4, [7, 8]]
print(x[2][1])
# 8
n=int(input())
res=[]
grade=[]
for i in range(n):
name=input()
mark=float(input())
res.append([name,mark])
grade.append(mark) #calculation 2nd lowest
#print(res)
#print(grade)
grade=sorted(set(grade)) #sorted unique
#print(grade)
m=grade[1]
#print(m)
name=[]
for val in res:
if m==val[1]:
name.append(val[0])
#print(name) #unsorted
name.sort()
#print(name) #sorted
for nm in name:
print(nm)