python - finding minimum index of a list -


hi guys need creating function find minimum index of list includes both list of strings , list of integers. right can function find either minimum index of list of integers or strings not both @ same time.

def find_index_of_min(l):     """     parameter: list l     returns: index of minimum element of list         (returns none if list empty)     """       if l == []:         return none     elif l == str:         min = 'z'         in range(len(l)):             if l[i] < min:                 min = l[i]                 min_index =         return min_index     elif l == int:         min = float('inf')         in range(len(l)):             if l[i] < min:                 min = l[i]                 min_index =         return min_index  import sys import math  def main():     """ read , print file's contents. """      # filename = str(input('name of input file: '))     # string = readfile(filename)     # print()     # print('the original list of cities is:')     # in range(len(string)):     # print(i, ':', string[i], sep="")      print(find_index_of_min([]))     print(find_index_of_min([3, 2, 1, 0]))     print(find_index_of_min(['a', 'z', 'y', 'b']))     print(find_index_of_min(['b', 'a', 'z', 'y']))  main() 

you need replace l == int , l == str (which valuated false) folowing:

all(isinstance(item, str) item in l)  # l == str all(isinstance(item, int) item in l)  # l == int 

Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -