Click here to Skip to main content
15,891,657 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have two list, a multidimensional list and a single list

cf = [[2000, 4000, 6000, 8000], [2000, 4000, 6000, 8000], [2000, 4000, 6000, 800]]
tev = [6000.0, 4800.0, 3480.0]

i want to dynamically subtract the value of the first element of the 2d list(cf[0]) from the value of the first element of tev[0]

which would be
2000 - 6000
4000 - 6000
6000 - 6000
8000 - 6000

and also do the same for the next element of both list

how do i go about that thanks

What I have tried:

i tried the following code but its not working

cf = [[2000, 4000, 6000, 8000], [2000, 4000, 6000, 8000], [2000, 4000, 6000, 800]]
tev = [6000.0, 4800.0, 3480.0]

for i in cf:
for u in i:
print [u * j for j in tev]
Posted
Comments
Richard MacCutchan 9-Feb-18 8:57am    
"subtract the value of the first element of the 2d list(cf[0]) from the value of the first element of tev[0]"
that is 6000.0 - 2000.0.

But in your code you are trying multiplication.

Please edit your question and clarify exactly what you want to do.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900