def inner_product(vec1,vec2):
if len(vec1)==len(vec2) and len(vec1)!=0:
return sum([vec1[n]*vec2[n] for n in range(len(vec1))])
else:
return 0
Is the code that I built contain using list comprehension? if yes what can I do instead of this?
Yes.
Without list comprehension, it would be something like below.