Python program to get a list ,sorted in increasing order by the last element each tuple from list

preview_player
Показать описание
The code to get a list,sorted in increasing order by the last
element in each tuple from a given list of non-empty
tuples

def last(n):
return n[0]
def sort(a):
return sorted(a,key=last)

a=[(2,5),(1,2),(4,4),(5,4)]
print("sorted:")
print(sort(a))

In this video, we will show you how to write a Python program to sort a list of tuples in increasing order by the last element of each tuple. We will walk you through the process of coding a function that takes a list of tuples as input and returns a new list that is sorted in increasing order by the last element of each tuple. We will explain the logic behind the program and provide examples of how to use the function. Whether you're a beginner looking to learn Python or a seasoned programmer looking for a quick refresher, this video will help you understand the basics of programming with Python. So, sit back, relax, and let's explore the world of Python programming together!
#pythonprogramming #listsorting #tuples #pythonfunctions #beginnerpython #pythonforbeginners #codingtutorial #learnpython #pythonbasics #programmingsyntax #pythonlogic #pythoncode #computerscience #codingeducation #codingtips #tutorialvideos #pythonlearning #pythontutorial #programmingforbeginners #datatypes #listoperations
Рекомендации по теме
Комментарии
Автор

Without def():

a=[(2, 5), (1, 2), (4, 4), (2, 3), (2, 1)]
for i in range(len(a)):
for j in range(len(a)):
if a[i][1]<a[j][1]:
a[i], a[j]=a[j], a[i]
print(a)








virmani
Автор

def last n function ko call hi nhi kiya to ye kaam kse kr rha h

yashovardhansaini
Автор

can it be done without using the def function?

hellothere
Автор

Bhai eske alava koi way he solve krne ka

-rohitpurbiya