Why does the if != j not need to know what list it's accessing unlike list [i]? If it does already know how so? Why can't I just do if i + j == t because the i and j variable already work when checking if i != j. I know list[i] accesses the list index but don't if i + j == t work too? Please explain in simple words. A kind answer is appreciated.
list = [3, 9 , 23, 4, 2]
t = 12
for i in range(len(list)):
for j in range(len(list)):
if i != j:
if list[i] + list[j] == t:
print(list[i] + list[j])
I tried changing it so that list[i] was written as i but it didn't work. The console was empty. I expected it to show the desired output(self explanatory).