Answers for "Given a list of strings, return a list with the strings in sorted order, except group all the strings that begin with 'a' first. python"

0

Given a list of strings, return a list with the strings in sorted order, except group all the strings that begin with 'a' first. python

list = ['mix', 'xyz', 'apple', 'xanadu', 'aardvark']
x_list = []
def sort(list):
    for element in list[:]:
        if element.startswith('a'):
            x_list.append(element)
            list.remove(element)
    print (sorted(x_list) + sorted(list))
    del x_list[:]
sort(list)
Posted by: Guest on October-18-2021

Code answers related to "Given a list of strings, return a list with the strings in sorted order, except group all the strings that begin with 'a' first. python"

Python Answers by Framework

Browse Popular Code Answers by Language