Nested Lists | Python | HackerRank

Nested Lists | Python | HackerRank

Coding Cart

3 года назад

39,974 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

lucifer m
lucifer m - 15.10.2023 19:26

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)


my programme

Ответить
Karthik Venkataram
Karthik Venkataram - 31.07.2023 20:38

Thank you Excellent teaching.

Instead of using another FOR LOOP in the end to just sort the names, we can use,

for val in sorted(res):
if m==val[1]
print(val[0])

Ответить
Navaneeth Navvi
Navaneeth Navvi - 10.03.2023 17:15

mark = float(input())
EOFError: EOF when reading a line.
I am getting like this sir plz give me solution

Ответить
Navdeep Sidhu
Navdeep Sidhu - 02.03.2023 07:42

recently started learning to code, this was a way better explanation compared to other sources. thanks /\

Ответить
Sandipan Sarkar
Sandipan Sarkar - 31.01.2023 23:03

finished watching

Ответить
ANKITA MEHTA
ANKITA MEHTA - 31.01.2023 09:42

You have made coding so easy.Thankyou so much

Ответить
aaa
aaa - 24.01.2023 21:45

thx a lot

Ответить
Ramya kotike
Ramya kotike - 06.01.2023 19:03

Thank you sir

Ответить
suraj rathod
suraj rathod - 19.12.2022 05:49

nice explanation sir.....

Ответить
Underachiever
Underachiever - 05.12.2022 23:04

Really nice explanation

Ответить
Kayla Lo
Kayla Lo - 24.11.2022 19:44

the explanation is clear, awesome

Ответить
Saurabh Anand
Saurabh Anand - 15.11.2022 16:57

very well explained

Ответить
Learner
Learner - 02.11.2022 01:14

i really like the way of your explanation .... you explanation is mind blowing........😇😇😇

Ответить
Alka Mankar
Alka Mankar - 14.10.2022 21:27

You are a great teacher! What a nice explanation!

Ответить
Ryo Styles
Ryo Styles - 12.10.2022 20:28

Great job there. Although I used a different method, your video helped me to link the least with the student name:
(it got only 7/10 but I'm happy that my own idea worked little. I'll use your idea to improve mine :) )
if _name_ == '__main__':

n = int(input("Enter number of students: "))
data = [] # list of name and score
jscore = [] # list of just the score


for i in range(1, n+1):
name = str(input(f"Enter name of student {i}: "))
score = float(input(f"Enter the score of student {i}: "))
lis = [name, score] # to temporarily store each student data entry
data.append(lis) # added to data list


for student in data:
jscore.append(student[1]) # just the list of scores

least1 = min(jscore) # first least score

while least1 in jscore:
# to remove first least score even if it's present multiple times
jscore.remove(least1)

least2 = jscore[0] # second least score

names = [] # to store names of students who have second least score
for student in data:
if least2 == student[1]: # matching second least score to students in data list
names.append(student[0])

for person in (sorted(names)): # sorting alphabetically and printing each name in new line
print(person)

Ответить
Saurabh Yeola
Saurabh Yeola - 05.10.2022 13:24

loved the way of explanation

Ответить
Dhruba Dutta Banik
Dhruba Dutta Banik - 04.10.2022 17:11

carry on 😌

Ответить
Kasun Dhananjaya
Kasun Dhananjaya - 01.10.2022 12:40

❤🙏

Ответить
avni mahajan
avni mahajan - 19.09.2022 19:16

Hi
can someone explain the code from line number 16.
I'm not clear with the val is being accessed with the indexing in the nested loop. To access element in nested loop won't it be. How will the for loop iterate with val in res?
to access the first val in res. won't we write to access the first element inside the inner list:like val[0, 0]

Ответить
Dhivya dharshini J
Dhivya dharshini J - 17.09.2022 19:33

why am I getting this IndexError: list index out of range

Ответить
Aman Singh
Aman Singh - 11.09.2022 16:18

Very well explained 🙌🏻❤️

Ответить
Haseeb Mohammed
Haseeb Mohammed - 06.09.2022 12:49

Great explanation

Ответить
Prayag Padwal
Prayag Padwal - 29.08.2022 23:47

Thank you man!

Ответить
Ziane Abdelkbir
Ziane Abdelkbir - 17.08.2022 05:19

good explained. Thank you

Ответить
Manoj Kp
Manoj Kp - 10.08.2022 21:10

nice bro thanks for clarity🥰

Ответить
Mahima Kumari
Mahima Kumari - 15.07.2022 18:11

Wow!!! how perfectly you explained each line of the code ,you explained all the logic behind each line so perfectly. Thankyou so much for the explanation. 😇

Ответить
Charankumar.P
Charankumar.P - 11.07.2022 18:29

Excellent teaching bro. Really I see so many but I can't understand .. once saw your video clear cut explanation.....do like this way of teaching

Ответить
Kumod sharma
Kumod sharma - 07.07.2022 17:05

Wow amazing and simple concept . thanku for your great explanation

Ответить
Roma Patel
Roma Patel - 02.07.2022 13:29

excellent explanation sir but ..while submitting code test case 3,4,6,9 are getting failed

Ответить
Astitva Kesharwani
Astitva Kesharwani - 01.04.2022 08:29

bhai kya bath hai yaar you're amazing

Ответить
Entertainment ADDA
Entertainment ADDA - 02.03.2022 18:42

Very neatly explained. Thank you

Ответить
Mohamed Medhat
Mohamed Medhat - 13.02.2022 21:05

high quality content. thank you so much

Ответить
Saurabh Thapa_EN_0025
Saurabh Thapa_EN_0025 - 28.01.2022 17:15

Thank you so much sir . The way you explain really cool . 😇🙂

Ответить
Manoj Singh
Manoj Singh - 04.01.2022 16:12

thanks sir its really goad explanation for every one to understood code easily. and its very helpfull for me . u are great

Ответить
Peter Eziagor
Peter Eziagor - 22.12.2021 19:29

thank you very much bro

Ответить
Prajyot Gurav
Prajyot Gurav - 20.12.2021 09:44

excellent. but this code do not run if there are multiple high grades.

Ответить
Prashant Chaudhary
Prashant Chaudhary - 09.12.2021 20:45

Nice explanation I searched everywhere but all were shortcuts, thanks a lot

Ответить
DUBBA SUDHA
DUBBA SUDHA - 15.11.2021 05:31

Thank you so much for this easy explanation!

Ответить
Aparajita Kumari
Aparajita Kumari - 31.10.2021 03:55

Thank you
It was very easy to follow.

Ответить
andresyah
andresyah - 19.10.2021 17:24

thanks bro 👍🏻

Ответить
Harshavardhan Kanoj
Harshavardhan Kanoj - 09.10.2021 06:28

Thank you

Ответить
trilochan rajesh
trilochan rajesh - 04.10.2021 17:39

Thanks for such a wonderful explanation. I very much happy after seeing such a video. Thanks

Ответить
Anand Malba
Anand Malba - 21.09.2021 13:19

Tqs bro for explaining in a clear manner 👏👏

Ответить
Andalib Jahin
Andalib Jahin - 21.09.2021 09:35

thank you brother.... its really helpful to understand

Ответить
Eunos Ali Mullah
Eunos Ali Mullah - 04.09.2021 08:13

I am getting error . will u please help?


n=int(input())
res=[]
grade=[]
for i in range(n):
name=input()
score = float(input())
res.append([name,score])
grade.append([score])
grade=sorted(set(grade))
m=grade[1]
name=[]
for val in res:
if val[1]==m:
name.append(val[0])
name.sort
for i in name:
print(i)


Error:
grade=sorted(set(grade))
TypeError: unhashable type: 'list

Ответить
yousefi azkco
yousefi azkco - 02.09.2021 18:54

Thank you so much..really really well explained

Ответить
Gaurav Rajguru
Gaurav Rajguru - 02.09.2021 05:09

good explaination

Ответить