Python Find the Smallest Element in a List
Define a list of numbers and find the smallest element in the list.
For example:
输入 : list1 = [10, 20, 4] 输出 : 4
Example 1
list1 = [10, 20, 4, 45, 99]
list1.sort()
print("The smallest element is:", *list1[:1])
list1.sort()
print("The smallest element is:", *list1[:1])
The output result of the above example is:
最小元素为: 4
Example 2: Using the min() method
list1 = [10, 20, 1, 45, 99]
print("The smallest element is:", min(list1))
print("The smallest element is:", min(list1))
The output result of the above example is:
最小元素为: 1Other Extensions
Python3 Examples