How do you find Lp-norm without using any python library?
def norm(vec, p):
# p is scalar
# where vec is a vector in list type
pass
Using numpy for instance would be more efficient, but with bare python you can do:
def norm(vec, p):
return sum([i**p for i in vec])**(1/p)