Is there a way to list the numbers in the Python list by size?

Asked 2 years ago, Updated 2 years ago, 17 views

Is there a way to literally list the numbers in Python by size?

For example,

s=[2,1,4,3] When

s=[1,2,3,4] How to list it as. It's a list that only contains integers.

python

2022-09-22 20:42

1 Answers

Use the sort method. The instructions are as follows:

s = [5,4,3,2,1]
s.sort()
print(s)


2022-09-22 20:42

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.