very new coder here. I'm trying to solve the classic twonums LeetCode problem (https://leetcode.com/problems/two-sum/) using some of the basics I have learned so far. I can get my program to find the indices of the solutions, but can't seem to make it recognize when the indices are the same and ignore that solution. Most likely I am just not ready for this problem yet, but I'm curious if it's possible with these tools and I'm missing something. Any and all help is appreciated.
num = [3, 3]
target = 6
def twonum(num):
for x in num:
for y in num:
a = num.index(x)
b = num.index(y)
if (x + y == target) and (a != b):
return(f'{b, a}')
break
ans = twonum(num)
print(ans)