I watched discussions on hackerrank, so many videos on youtube to explain this question to me but everyone was explaining this in such a complicated way that i thought that this was too difficult for me and was about to give up when i found this video... I truly believe now that if the teacher is great, you'll actually understand and enjoy coding!
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])
res=[] grade=[] for _ in range(int(input())): name = input() score = float(input()) res.append([name,score]) grade.append(score) a=set(grade) a.remove(min(a)) g=[] for i in res: if i[1]==min(a): g.append(i[0]) for i in sorted(g): print(i) #i try this and it was also worked
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. 😇
Glad you liked it 😊. Start your linked List problem solving with a simple problem like "Palindrome check for a Linked List" with different different approaches. Approach 1: using string th-cam.com/video/CnH48nmU8BI/w-d-xo.html Approach 2: using stack th-cam.com/video/litQHGRRSdo/w-d-xo.html Approach 3: using list th-cam.com/video/71lls_x4VdY/w-d-xo.html Approach 4: using two pointer concept th-cam.com/video/DxvET45WAgE/w-d-xo.html Approach 5: using two pointer and a list th-cam.com/video/o-bnjsY2Hck/w-d-xo.html
Traceback (most recent call last): File "Solution.py", line 10, in m=grade[1] IndexError: list index out of rangeTraceback (most recent call last): File "Solution.py", line 10, in m=grade[1] IndexError: list index out of range
You might be accessing the list value which is out of its range. Instead of only posting the error you could have posted your solution too so that anyone could have helped by seeing the code.
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
Glad you liked it 😊 Do share with your friends too. You can also watch the latest video on linked list swap nodes problem from leetcode th-cam.com/video/_oJYnuulSL0/w-d-xo.html
can we procced like this ? my_dict = {'adam':21, 'bob':32, 'corey':43, 'darek':26, 'euler':24, 'mark':24, 'gen':24} val = list(my_dict.values()) names = list(my_dict.keys()) val.remove(min(val)) second_low = val result_val = min(val) runner_ups = [] for key,val in my_dict.items(): if val == result_val: runner_ups.append(key) print(sorted(runner_ups))
Sir I have a doubt, In 15th line you have made an empty list of 'name' But we have already a variable with the same 'name' in the 5th line, can you please explain?
Yes. 5th line name variable is for taking the user input which is used only in that for loop for storing in res, so instead of taking another variable i have taken the same name as list type.. but if you are getting confused you can take different variable name :)
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]
@@codingcart n = int(input()) res = [] grade = [] for i in range(n): name = str(input()) marks = float(input()) res.append([name, marks]) grade.append([marks]) print(res) print(grade) grade = sorted(set(grade)) print(grade) second_lowest = grade[1] print(second_lowest) aim_name = [] for val in res: if val == second_lowest: name.append(aim_name) print(aim_name) print(sorted(aim_name)) for nm in aim_name: print(nm)
Traceback (most recent call last): File "Solution.py", line 12, in m=grade[1] IndexError: list index out of range this error is coming on m =grade[1] please help
if __name__ == '__main__': result=[] grades=[] for _ in range(int(input())): name = input() score = float(input()) result.append([name,score]) grades.append(score) grades=sorted(set(grades)) n=grades[1] name=[] for x in result: if x[1]==n: name.append(x[0]) name.sort() for y in name: print(y)
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)
here is the modified one: if __name__ == '__main__':
n = int(input()) data = [] # list of name and score jscore = [] # list of just the score
for i in range(1, n+1): name = str(input()) score = float(input()) 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
unique = sorted(list(set(jscore))) least = unique[1]
names = [] # to store names of students who have second least score for student in data: if least == 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)
Note: Make sure to use sorted function after converting the set into list because if you sort the list first, then convert into set and later covert it back to a list, the order may change and give you wrong answer. So use sorted at last =====>ref: variable "unique"
I really liked the way you explained the logic and the code line by line and step by step, Keep this method alive for all the videos.
Glad you liked it!
I watched discussions on hackerrank, so many videos on youtube to explain this question to me but everyone was explaining this in such a complicated way that i thought that this was too difficult for me and was about to give up when i found this video... I truly believe now that if the teacher is great, you'll actually understand and enjoy coding!
Great to hear that 😊.
Keep learning keep supporting 😊
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])
Glad it helped😊. Please do share with your friends too😊
res=[]
grade=[]
for _ in range(int(input())):
name = input()
score = float(input())
res.append([name,score])
grade.append(score)
a=set(grade)
a.remove(min(a))
g=[]
for i in res:
if i[1]==min(a):
g.append(i[0])
for i in sorted(g):
print(i)
#i try this and it was also worked
yes it's working
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
Glad you liked it 😊. Do share with your friends too 🙂
Awesome Brother.....Keep up the good work...First time got this type video on youtube
Thanks a ton
Thanks for such a wonderful explanation. I very much happy after seeing such a video. Thanks
Glad to hear that
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. 😇
Glad you liked it ☺️. Do share with your friends too 🙂
Nice explanation I searched everywhere but all were shortcuts, thanks a lot
Glad you liked it😊
Wow amazing and simple concept . thanku for your great explanation
Best Explanation. Thank you so much. you are doing great job
You are most welcome
Super kya baat h maza aa gaya
Glad you liked it :)
Superb explanation my friend....
Such a brilliant explanation
Glad to hear that😊
You have made coding so easy.Thankyou so much
Glad you liked it 😊
Please share it with your friends too😊
i really like the way of your explanation .... you explanation is mind blowing........😇😇😇
Glad you liked it 😊.
Start your linked List problem solving with a simple problem like
"Palindrome check for a Linked List" with different different approaches.
Approach 1: using string
th-cam.com/video/CnH48nmU8BI/w-d-xo.html
Approach 2: using stack
th-cam.com/video/litQHGRRSdo/w-d-xo.html
Approach 3: using list
th-cam.com/video/71lls_x4VdY/w-d-xo.html
Approach 4: using two pointer concept
th-cam.com/video/DxvET45WAgE/w-d-xo.html
Approach 5: using two pointer and a list
th-cam.com/video/o-bnjsY2Hck/w-d-xo.html
thanks sir its really goad explanation for every one to understood code easily. and its very helpfull for me . u are great
Glad to hear that 😊.
Keep learning keep supporting 😊
the explanation is clear, awesome
i didn't thought about using sets in the python
too good sir
Traceback (most recent call last):
File "Solution.py", line 10, in
m=grade[1]
IndexError: list index out of rangeTraceback (most recent call last):
File "Solution.py", line 10, in
m=grade[1]
IndexError: list index out of range
You might be accessing the list value which is out of its range.
Instead of only posting the error you could have posted your solution too so that anyone could have helped by seeing the code.
@@codingcart I got the solution. That was indentation error. Thanks a lot
Outstanding logic
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
explanation is great....
your explanation helped a lot, thanks. keep up the good work.
This is Genious brother. Keep it up! And also solve the placement questions of company if you find !! Thanks again!!👍🏻
Sure 👍 Please do share with your friends and juniors too :)
Very neatly explained. Thank you
Awesome explanation....🎉🎉
Glad it helped😊. Please do share with your friends too😊
Best explanation ever 🤝🏻🤝🏻
Thank you so much! Clear Explanation.
Really a great video. I understood really well. its very helpful. keep up the good work.
And pls post more of such videos
good explained. Thank you
that set logic in python is too good sir
Thanks for easy explanation
Glad it helped
bhai kya bath hai yaar you're amazing
Keep Learning Keep Supporting :)
explanation is really understandable!!
nice explanation 👌
Thank you 😃
thank you so much, these videos are such a game changer to my learning. keep it up
Happy to hear that!
loved the way of explanation
Glad you liked it 😊
Do share with your friends too. You can also watch the latest video on linked list swap nodes problem from leetcode
th-cam.com/video/_oJYnuulSL0/w-d-xo.html
wonderful explanation bro i was searching for one like you
thank you brother.... its really helpful to understand
Keep learning keep supporting 😊
Very well explained 🙌🏻❤️
Thank you so much for this easy explanation!
high quality content. thank you so much
Bro the way u r explaining is on another level 🔥
Glad you think so!
Thank you
It was very easy to follow.
Really nice explanation
Glad you liked it 😊. Do share with your friends too 😊
great explanation man .. Thanks for the help !!!
Tqs bro for explaining in a clear manner 👏👏
Keep learning keep supporting 😊
Perfect explanation!! Crystal clear
Glad you think so!
nice explanation sir.....
Thanks :) do share with your friends too.
Awesome
You are a great teacher! What a nice explanation!
Thanks 😊. Keep learning and please share with your friends too 😊
Thank you so much sir . The way you explain really cool . 😇🙂
Thanks and welcome
recently started learning to code, this was a way better explanation compared to other sources. thanks _/\_
Glad you liked it😊
Please do share with your friends too 😊
Great explanation
Glad you liked it 😊. Do share with your friends too 🙂
very well explained
Awesome 🔥
Thanks 🔥
awesome
nice bro thanks for clarity🥰
Keep learning and keep supporting 😊
You are the best 👌🏻
Thanks :)
Keep learning keep supporting .
Thank you so much..really really well explained
Bro your video has really helped me🔥
🙌
Thank you so much! Really well explained!
Glad it was helpful!
excellent
Thanks!
Thank you sir
good explaination
can we procced like this ?
my_dict = {'adam':21, 'bob':32, 'corey':43, 'darek':26, 'euler':24, 'mark':24, 'gen':24}
val = list(my_dict.values())
names = list(my_dict.keys())
val.remove(min(val))
second_low = val
result_val = min(val)
runner_ups = []
for key,val in my_dict.items():
if val == result_val:
runner_ups.append(key)
print(sorted(runner_ups))
sorry, you are not using nested list
I am getting an error here that float is not transciptable. How to resolve?
Awesome job dude
use alphabetical order instead of ascending order
Thanks for the tip
can we also use list comprehension instead of append
Just give a try😊
Great man Thanks..
You're welcome!
Sir I have a doubt, In 15th line you have made an empty list of 'name' But we have already a variable with the same 'name' in the 5th line, can you please explain?
Yes. 5th line name variable is for taking the user input which is used only in that for loop for storing in res, so instead of taking another variable i have taken the same name as list type.. but if you are getting confused you can take different variable name :)
thanks bro 👍🏻
Welcome 👍
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]
can someone explain how are they accessing list within list?
memory of the nested list
i'm not clear with for loop in line 16
finished watching
carry on 😌
excellent explanation sir but ..while submitting code test case 3,4,6,9 are getting failed
Share your code.. you might be missing small thing😊
thank you very much bro
Always welcome
Thank you man!
Glad you liked it 😊. Please share with your friends too 🙂
Error (stderr)
Traceback (most recent call last):
File "Solution.py", line 11, in
TypeError: 'list' objects are unhashable
getting this error
grade= sorted(set(grade)) , it's not working saying error. help me brother
Please share your code
@@codingcart n = int(input())
res = []
grade = []
for i in range(n):
name = str(input())
marks = float(input())
res.append([name, marks])
grade.append([marks])
print(res)
print(grade)
grade = sorted(set(grade))
print(grade)
second_lowest = grade[1]
print(second_lowest)
aim_name = []
for val in res:
if val == second_lowest:
name.append(aim_name)
print(aim_name)
print(sorted(aim_name))
for nm in aim_name:
print(nm)
Getting an error of 'float' object is not transcriptable
mark = float(input())
EOFError: EOF when reading a line.
I am getting like this sir plz give me solution
Thanks!
Glad it helped😊. Please do share with your friends too😊
Perfect 👌👌
Glad you think so!
Thank you
You're welcome
Thanks bud
No problem 👍
Traceback (most recent call last):
File "Solution.py", line 12, in
m=grade[1]
IndexError: list index out of range
this error is coming on m =grade[1]
please help
perhaps there's an error with your indentation
if __name__ == '__main__':
result=[]
grades=[]
for _ in range(int(input())):
name = input()
score = float(input())
result.append([name,score])
grades.append(score)
grades=sorted(set(grades))
n=grades[1]
name=[]
for x in result:
if x[1]==n:
name.append(x[0])
name.sort()
for y in name:
print(y)
Thank you much more
You are very welcome
@@codingcart bro engineering 1st year what about they will teach
why am I getting this IndexError: list index out of range
thx a lot
You're welcome!
excellent. but this code do not run if there are multiple high grades.
❤🙏
🙏
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)
Great 😊 keep learning 🤘🏻
here is the modified one:
if __name__ == '__main__':
n = int(input())
data = [] # list of name and score
jscore = [] # list of just the score
for i in range(1, n+1):
name = str(input())
score = float(input())
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
unique = sorted(list(set(jscore)))
least = unique[1]
names = [] # to store names of students who have second least score
for student in data:
if least == 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)
Note: Make sure to use sorted function after converting the set into list because if you sort the list first, then convert into set and later covert it back to a list, the order may change and give you wrong answer. So use sorted at last =====>ref: variable "unique"
Thank you sir
excellent explanation
Glad you liked it!