python-3.xlistlis

How do I print out the specific index?


My code: text = [['Name', 'Surname', '2009']]

What I tried to do: text[1];

I want so that the 'Surname' would print out, but I keep getting - IndexError: list index out of range.


Solution

  • This is a nested list.

    text = [['Name', 'Surname', '2009']]
    
    text[0] = ['Name', 'Surname', '2009']
    
    text[0][1] = 'Surname'