# Sorting a list of strings
Nterms = int(input("Enter number of string:"))
Lstr = []
print("Enter", Nterms, "strings:")
for idx in range(0,Nterms, 1):
str1 = input()
Lstr.append(str1)
print("Original list of strings:")
print(Lstr)
Lstr = sorted(Lstr, key=lambda Lstr:Lstr[0], reverse=False)
print("List of strings after sorting:")
print(Lstr)
Nterms = int(input("Enter number of string:"))
Lstr = []
print("Enter", Nterms, "strings:")
for idx in range(0,Nterms, 1):
str1 = input()
Lstr.append(str1)
print("Original list of strings:")
print(Lstr)
Lstr = sorted(Lstr, key=lambda Lstr:Lstr[0], reverse=False)
print("List of strings after sorting:")
print(Lstr)
No comments:
Post a Comment
Don't be a silent reader...
Leave your comments...
Anu