'"Enter" doesn't work in VS Code for Python

I installed Anaconda. Somehow, afterwards, when I press Enter in Python files, it no longer works. This error shows up:

command 'pythonIndent.newlineAndIndent' not found

How do I solve this problem?



Solution 1:[1]

Search Enter in Keyboard Shortcuts and see if your wanted one is list there:

enter image description here

If not, search with your wanted effect that enter brings and see if you changed the keybindings, which you can see your customization in keybindings.json.

Or disable the third-party extension but only keep Python.

If the above don't work, you may reset VS Code.

Solution 2:[2]

uninstall python indent from vs code then again download the same extension.Hopefully now it works properly.

Solution 3:[3]

I had the same problem. I solved the problem by uninstalling an extension called "Python Indent"

Solution 4:[4]

I would say the first thing you have to figure out is how large is the resulting list that you want to return going to be. From what I can tell from your examples above, you keep adding lists of size group until the first row matches the last row. Once we know the size, then we can accurately create an array with appropriate sizes to stuff our data into, then return it.

public static int[][] arrayOfArrays(int[] arr, int step, int group) {
   int size = 0; // Keeps track of how many rows we got
   int c = 1; 
   // Figure out the size by counting by offset till we come back to starting with 1
   // Each time we count a full list add how many rows it would take 
   // to add that full list. Once we get back to starting with 1
   // Just add that final row
   while(true)
   {
       // Move number counter by how many indexes we will have moved in a list length
       c += step*(arr.length/group);

       // Because it wraps, lets do a modulo operation by the length of the array
       c %= arr.length;

       // Lets add how many rows we would have created this loop
       size += arr.length/group;

       if(c == 1) // Are we back to one as a first element in the row
       {
           size+=1; // Add one more for that final row
           break;
       }
   }
   // Now that we know size, lets make our array
   int[][] list = new int[size][group];

   // Stuff the array with data until we are done
   c = 1; // Reset our counter to 1
    for(int r = 0; r < size; r++)
    {
        for(int g = 0; g < group; g++)
        {
            list[r][g] = c;
            c = (c%arr.length) + 1; // Index and loop through the list
        }
    }
    return list;
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Molly Wang-MSFT
Solution 2 Aditya Dixit
Solution 3 Lithi
Solution 4 RoyceIrving