We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Python
- Basic Data Types
- Nested Lists
- Discussions
Nested Lists
Nested Lists
Sort by
recency
|
4677 Discussions
|
Please Login in order to post a comment
lst = []
for _ in range(int(input())): name = input() score = float(input()) lst.append([name, score])
Step 1: Extract all unique scores and sort them
scores = sorted(set([score for name, score in lst]))
Step 2: Get the second lowest score
second_lowest = scores[1]
Step 3: Get all names with the second lowest score
names = sorted([name for name, score in lst if score == second_lowest])
Step 4: Print the names
for name in names: print(name)
if name == 'main': add = [] for _ in range(int(input())): name = input() score = float(input()) add.append([name,score])
if name == 'main': t= int(input()) n=[] for _ in range(t): name = input() n.append(name) score = float(input()) n.append(score) s=[] for i in range(1,2*t,2): s.append(n[i]) se = sorted(set(s) ) slo = se[1] res=[] for i in range(2*t): if n[i]==slo: res.append(n[i-1]) if len(res)>1: res.sort() print("\n".join(res)) else: print(res[0])