import unittest

def remove3s(L:list):
  i = 0
  while i < len(L):
    if isinstance(L[i],int):
      if L[i] == 3:
        del L[i]
        continue
    elif isinstance(L[i],list):
      remove3s(L[i])
    i += 1
            
class test_remove3s(unittest.TestCase):
  def test_remove3s(self):
    L = [[5, 3], 1, [4, [2, [3]]], 3]
    Lorig = L[0:]  # make a copy of L
    remove3s(L)
    expected = [[5], 1, [4, [2, []]] ]
    self.assertEqual( L, expected, 
                     "wrong on input " + str(Lorig) )

if __name__ == '__main__':
  unittest.main(exit=False, verbosity=2)  