### osdir.com

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

# Help!!! How to apply my created function to another function

```Please see the last line

When I put vectorMagnitude(A), it returns perfectly corrected that means my function create right. But when I try to put vectorMagnitude(B) which I was thinking to put new list from buildRandomVector(A),it returns an error. I have been attempting to import buildRandomVector(A) to a list, but I can not understand why the list can not apply to  vectorMagnitude(B).

Can you assist me in figuring the problem? Thank you!!

A = [ 4, 5, 1]

#TASK0

def displayVector(v) :

print(v)

displayVector(A)

#TASK1

def buildVector(v) :

print(v,v,v)

buildVector(A)

#TASK2

import random

def buildRandomVector(v) :

Z = []

for i in range(len(v)):

x = (random.randint(0, 9))

Z.append(x)

print(Z)

buildRandomVector(A)

#TASK3

import math

B = buildRandomVector(A)

def vectorMagnitude(v) :

tsum = 0

for i in v:

tsum = tsum + i**2

x = math.sqrt(tsum)

print(x)

vectorMagnitude(B)  ==>>>> this is problem

```