4. Write a python program to sort the programmer user as provided in the output below in increasing order.
The output is:
n_programmer = [('Python', 198), ('C', 112), ('R', 67)]
Expected Answer:
The initial list of tuples:
[('Python', 198), ('C', 112), ('R', 67)]
After sorting the list of tuples:
[('R', 67), ('C', 112), ('Python', 198)]
Sample Answer:
n_programmer = [('Python', 198), ('C', 112), ('R', 67)] print("The initial list of tuples:") print(n_programmer) n_programmer.sort(key = lambda x: x[1]) print("\nAfter sorting the list of tuples:") print(n_programmer)
More Exercises:
Python String ExercisesMore Numpy Exercises:
Numpy String ExercisesMore Pandas Exercises:
Pandas Series ExercisesMore Tutorials:
Python Installation - Linux (Ubuntu)