Python sort 🗄️
21.9 هزار بار بازدید -
4 سال پیش
-
Python sort sorting tutorial example
Python sort sorting tutorial example explained
#python #sorting #sort
-------------------------------------------------------------------
sort() method = used with lists
sort() function = used with iterables
students = (("Squidward", "F", 60),
("Sandy", "A", 33),
("Patrick","D", 36),
("Spongebob","B", 20),
("Mr.Krabs","C", 78))
grade = lambda grades:grades[1]
students.sort(key=age) # sorts current list
sorted_students = sorted(students,key=grade) # sorts and creates a new list
for i in sorted_students:
print(i)
-------------------------------------------------------------------
music credits 🎼 :
===========================================================
Up In My Jam (All Of A Sudden) by - Kubbi SoundCloud: kubbi
Creative Commons — Attribution-ShareAlike 3.0 Unported— CC BY-SA 3.0
Free Download / Stream: http://bit.ly/2JnDfCE
Music promoted by Audio Library Up In My Jam (All Of A Sudden) – Kubb...
===========================================================
#python #sorting #sort
-------------------------------------------------------------------
sort() method = used with lists
sort() function = used with iterables
students = (("Squidward", "F", 60),
("Sandy", "A", 33),
("Patrick","D", 36),
("Spongebob","B", 20),
("Mr.Krabs","C", 78))
grade = lambda grades:grades[1]
students.sort(key=age) # sorts current list
sorted_students = sorted(students,key=grade) # sorts and creates a new list
for i in sorted_students:
print(i)
-------------------------------------------------------------------
music credits 🎼 :
===========================================================
Up In My Jam (All Of A Sudden) by - Kubbi SoundCloud: kubbi
Creative Commons — Attribution-ShareAlike 3.0 Unported— CC BY-SA 3.0
Free Download / Stream: http://bit.ly/2JnDfCE
Music promoted by Audio Library Up In My Jam (All Of A Sudden) – Kubb...
===========================================================
4 سال پیش
در تاریخ 1399/10/29 منتشر شده
است.
21,992
بـار بازدید شده