#1

for index, val in enumerate(reversed(list)):

  print len(list) - index - 1, val

 

#2 

def reverse_enum(L):
  for index in reversed(xrange(len(L))):
    yield index, L[index]

L = ['foo', 'bar', 'bas']
for index, item in reverse_enum(L):
  print index, item

 

#3

L = ['foo', 'bar', 'bas']

for index in reversed(range(len(L))):
  print index, L[index]

posted on 2016-01-04 22:16  学思罔殆  阅读(539)  评论(0编辑  收藏  举报