I want to extract the value in a list if a conditional is met. For example in a list [0,0,3,4], I want to extract the value which when added to an index value gives 7, given that the index value of the adding term is higher. So far I can confirm that such a number exists within the list but cannot figure out how to extract the value to use it.
nums=[0,0,3,4]
target=7
for i in range(len(nums)):
n = target-nums[i] in nums[i+1:]
print (n)
Output:
False
False
True
False
Since the third output is true, that tells me that (7-3) is in the list at a higher index, but how can I assign the value to a variable rather than the boolean?