#10 : Nested List | hackerrank Python Solutions

preview_player
Показать описание
Thanks if u r Watching us....
#Python #Dev19 #HackerankSOlutions #C #C++ #Java #Python
Please Subscribe Us ....
Рекомендации по теме
Комментарии
Автор

The question has to done using Nested Lists and not using the dictionary. Appreciate your video
Here is the correct solution
if __name__ == '__main__':
students = []
scores = []
for N in range(int(input())):
name = input()
score = float(input())
scores.append(score)
students.append([name, score])


count = scores.count(min(scores))
for i in range(count):
scores.remove(min(scores))

secondHigh = min(scores)

students.sort()
output = [x for x in students if x[1] == secondHigh]
for i in output:
print(i[0])

spanningTree
Автор

you have explained the logic in a very good way.

tayus_animations
Автор

if __name__ == '__main__':
students = []
for _ in range(int(input())):
name = input()
score = float(input())
students.append([name, score])

second_lowest = sorted(list(set([x[1] for x in students])))[1]
for name in sorted([x[0] for x in students if x[1] == second_lowest]):
print(name)

Bhongaon
Автор

Thank you for the video, I am from Taiwan, it will be great if you can speak English throughout for the future tutorials ~

NightlyNewsChat
Автор

Keep doing this, you are really doing amazing

HappyHour
Автор

List = []
s = []
for _ in range(int( input())):
name = input()
score= float( input())
List.append([name, score])
s.append( score)
a = min(s)
while(a in s):
s.remove(a)

b = min(s)
List.sort()
for i in range(len(List)):
if(List[i][1]==b):
print(List[i][0])

priyashakya
Автор

dic={}
if __name__ == '__main__':
names=list()
scores=list()
l=list()
for i in range(0, int(input())):
name = input()
score = float(input())
if score in dic:
dic[score].append(name)
else:
dic[score]=[name]
names.append(name)
scores.append(score)
l.append([name, score])

s=sorted(set(scores))[1]
for i in sorted(dic[s]):
print(i)

preetmehta
Автор

bhai volume badha lo yrr ! kuch samaj ni aa rha...

shivamparashar
Автор

if __name__ == '__main__':

ls = []
n = int(input())
for _ in range(n):
name = input()
score = float(input())
ls.append([name, score)
ls.sort(key=lambda x: x[1])
lowest_score = ls[0][1]
second_lowest_score = None
for i in range(1, n):
if ls[i][1] > lowest_score:
second_lowest_score = ls[i][1]
break
result = [name for name, score in ls if score == second_lowest_score]
result.sort()
for name in result:
print(name)

niharsampath
Автор

Did you just copy the exact same solution from the editorial?

Yoohooooo
Автор

the Problem has to be solved using the nested list. that’s why my and you’re code is so different :)

JashSingh-bvge
Автор

l1=[]
l2=[]
for i in range(int(input("Enter how many students: "))):
name=input("Enter your names: ")
marks=float(input("Enter numbers: "))
l1.append([name, marks])
l2.append(marks)
l2=list(sorted(set(l2)))
lo=l2[1]
l3=[]
for i in l1:
if lo==i[1]:
l3.append(i[0])
l3.sort()
for i in l3:
print(i)


BRO TRY THIS :)

luciferm-ue
Автор

#Create arrays according to the number mentioned in the first input
n = int(input())

students_list = [ ]

#Distribute the first (name) and second (grade) value to the first array and so on until all the arrays are finished
for _ in range(0, n):
name = input()
grade = float(input())
students_list.append([name, grade])

#Sort grades by lowest to highest
students_list = sorted(students_list, key=lambda student: student[1])

#Assign value to the lowest grade
lowest_grade = students_list[0][1]

#Assign value to the second lowest grade
for name, grade in students_list:
if grade > lowest_grade:
second_lowest_grade = grade
break

#Filter and sort names alphabetically
second_lowest_names = sorted([name for name, grade in students_list if grade == second_lowest_grade])

#Print the sorted names
if second_lowest_names:
for name in second_lowest_names:
print(name)

machour
Автор

bhai hindi may bol if you dont know english, their is not a problem in speaking in hindi bhai tu dhono language may bolra a na tho kuch nahi sumuj aara english to bol tura or hindi to bol

OMKARDESHMUKH-kj
Автор

I understand Hindi/Urdu a little bit to know what youre saying :)

IdleDeathGambling
Автор

Can we use append method in dictionary?

ksquarev-kkv
welcome to shbcf.ru