I am writing a program to check the opening and closeing tags of an html document. To do this I am putting string vertions of the tags in a list and comparing the last index of the list to the second-to-last index of the list. What I want to do is, if the letters of index[-2] from 2:-1 are the same as all of the letters in index-1 from , I want to remove both of them from the list. My problem is that I dont know how to compare specific letter of a string within a list, to the letters of a different string within that same list. In pseudocode what I am trying to do may look something like this:
someList=['<head>','</head>]
if someList[-2,2:-1] in someList[-1,1:-1]: # the 2:-1 & 1:-1 referencing the letters of the string in index -2 and -1
remove someList[-1] and someList[-2]
I would be happy to answer any questions if the description is not clear enough.
someList=['<head>','</head>]
if someList[-2,2:-1] in someList[-1,1:-1]: # the 2:-1 & 1:-1 referencing the letters of the string in index -2 and -1
remove someList[-1] and someList[-2]
I would be happy to answer any questions if the description is not clear enough.