x = [4,6,2,1,7,9]
y= sorted(x)
x
[4,6,2,1,7,9]
y
[1,2,4,6,7,9]
Sorted function very similar to 'sort'. Can also be used on a sequence:
sorted('Python')
['P,' 'h', 'o', 'n', 't', 'y']
Arranges the string into an alphabetical sequence.
/* */
No comments:
Post a Comment