How to loop over a list in sorted order with Python

1 Answer

0 votes
lst = ['x', 't', 'c', 'q', 'o', 'a', 'z', 'e', 'b', 'm']

for ch in sorted(lst):
    print(ch)




'''
run:

a
b
c
e
m
o
q
t
x
z

'''

 



answered Feb 25, 2023 by avibootz

Related questions

...