my_list = ['ab', 'abc', 'abcd']
for i=0; i<len(my_list); i++
for j=i+1; j<len(my_list); j++:
print(my_list[i], my_list[j])
I need two loops like above (in Java or C++) to compare elements with each other. How to do this similarly in Python? I was trying to do this, but it didn't work:
for index, value in enumerate(my_list, start=0):
for index2, value2 in enumerate(my_list, start=1):
print(value, value2)
It turns out that the outcome are not the same.