I have been coding in C++ and Java for some time. I have started to code in Python recently as well. However, I got stuck in the case of nested for loops in Python. I have written following code in C++. What will be the equivalent code of it in Python?
for(int i = 0; i<a.size();i++){
for(int j = i; j<a.size();j++)
{
if a[i] != a[j]
/*some code */
}
}
I tried to use enumerate as follows, but it fails:
for i, val in enumerate(lst):
for j=i,val2 in enumerate(lst):
if val != val2
#some code
So how can I represent the C++ nested loops in python?