-3
pola2 = [['%3C','%28'],['%3C','document.cookie','%3B'],['%3C','%28','%27','4'],['%3C','document.cookie','%3B','4','5'],['%3C','document.cookie','%3B','4','5','6']]
#find the longest list in list
a = max(pola2, key=len)
print a
#result ['%3C', 'document.cookie', '%3B', '4', '5', '6']
#how if end of result is index "4" or position "5"

How do I print the result of print a as it appears in index 4 or position 5 in the pola2 list?

Michael Dodd
  • 10,102
  • 12
  • 51
  • 64
Goviella
  • 1
  • 2

1 Answers1

0

Give a try with the code bellow:

pola2 = [['%3C','%28'],['%3C','document.cookie','%3B'],['%3C','%28','%27','4'],['%3C','document.cookie','%3B','4','5'],['%3C','document.cookie','%3B','4','5','6']]
a = max(pola2, key=len)
print pola2.index(a)

Should work fine. And the question is kind of duplicated, see: Finding the index of an item given a list containing it in Python

Esdras Xavier
  • 867
  • 1
  • 7
  • 18