Why does my code not remove the last empty element in the list?
templist = ['', 'hello', '', 'hi', 'mkay', '', '']
for element in templist:
if element == '':
templist.remove(element)
print (templist)
Output:
['hello', 'hi', 'mkay', '']