Python - Removing an element in list
How would i go about hiding the last element from a list. For example, Python outputs ['Go shopping @H']. Just wondering what code would I use to remove the @H from the result.
If you want to remove the last two characters, you can do this:
If you want to remove an element followed by @, you can do this:
import re l=re.sub("@[a-zA-Z]*",'',l)
If you print l after any of these operations, you'll get ['Go shopping '].
If you need to do the same for each element of the list, you can loop through it removing the thing you want to remove.
for x in xrange(0, len(your_list)-1): your_list[x]= # use one of the methods mentioned above