In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Today, I would like to share with you the relevant knowledge points about how to return the minimum index in Python. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article.
Returns the index of the smallest item in the list
Def indexofMin (arr): minindex = 0 currentindex = 1 while currentindex < len (arr): if arr [currentindex] < arr [minindex]: minindex = currentindex currentindex + = 1 return minindexarr = [3, 5, 2, 1] print (indexofMin (arr))
Add: python returns the maximum (minimum) value in the list and its index
1. Returns the maximum of the list
Usage: max ()
Its syntax: this function returns the maximum value of a given parameter, which can be a sequence.
N = max (list) # list represents the list of maximum values to be returned.
Result: returns the maximum value in the list element
List1 = [123,456,789] list2 = ['123,' 456, '789'] list3 = ['abc',' abb', 'acb'] print (max (list1)) # 789print (max (list2)) # 789print (max (list3)) # acb2. Returns the index of the maximum value of the list
Usage: use max to find the maximum value in the list
Use index () to find the index with the maximum value
This function returns the index of the given parameter, which is an element in the sequence.
List1.index (max (list1))
The result returns the index of the parameter in the list
List1 = [123,456,789] print (list1.index (456)) # 1print (list1.index (max (list1) # 2
The minimum value only needs to be changed from max to min.
These are all the contents of the article "how to return the minimum Index in Python". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.