A function in Python that sorts a list
def sortlist(listname, string):
if string == "asc":
return sorted(listname)
elif string == "desc":
return sorted(listname, reverse=True)
elif string == "none":
return listname
else:
print("Wrong Input!")
list1 = [4,8,6,1,9,56,33,19,2,55,14]
list2 = ["z","v","c","r","h","a","s","m","f"]
print(sortlist(list2, "none"))
Comments
Post a Comment
Write something to CodeWithAbdur!