What is the runtime complexity of python list functions?

后端 未结 5 1705
無奈伤痛
無奈伤痛 2020-12-03 06:18

I was writing a python function that looked something like this

def foo(some_list):
   for i in range(0, len(some_list)):
       bar(some_list[i], i)
         


        
5条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-03 07:03

    if you need index and value then use enumerate:

    for idx, item in enumerate(range(10, 100, 10)):
        print idx, item
    

提交回复
热议问题