Matthew Pearson Matthew Pearson - 7 months ago 44
Python Question

del x[n] not working

I have a list and I am trying to remove the first item in it

I have tried to use this code, but it doesn't do anything

del rows[rows.index(userInfo)][9].split()[0]

for context


finds an item in a list which is a string then splits the string into a list, this string is

Skyfall Skyfall DarkKnight DieHard CaptainAmerica Deadpool TheMatrix CaptainAmerica TheMatrix CaptainAmerica TheBourneIdentity


You can use pop() or index it out with slicing like this:

rows[rows.index(userInfo)][9] = " ".join(rows[rows.index(userInfo)][9].split().pop())


rows[rows.index(userInfo)][9] = " ".join(rows[rows.index(userInfo)][9].split()[1:])