The last line can be replaced by the slightly simpler norm = assemble(grad(f)[0]*dx) to get the same bug.
The last line can be replaced by the slightly simpler grad(f) [0]*dx)
norm = assemble(
to get the same bug.