0

I have this code and VScode is underlining most of it in blue. What is the reason and how do we solve it?

# Python code to count minimum deletions required
# so that there are no consecutive characters left\
def countDeletions(string):
    ans = 0
    for i in range(len(string) - 1):
         
        # If two consecutive characters are
        # the same, delete one of them.
        if (string[i] == string[i + 1]):
            ans += 1
         
    return ans
  
# Driver code
string = "AAABBB"
 
# Function call to print answer
print(countDeletions(string))

enter image description here

Mahmoud Saad
  • 107
  • 1
  • 10
  • 3
    What happens if you hover over the lines? Does it tell you? Blue squigglies in VSCode usually means your code has correct syntax but can't be run for some reason. – wkl Jul 26 '22 at 22:50
  • 4
    I suggest you delete the backslash at the end of the comment in line 2. That MAY be confusing VSCode's parser into thinking that the next line is part of the comment. – Tim Roberts Jul 26 '22 at 22:52
  • https://stackoverflow.com/a/69535248/2823755 ?? – wwii Jul 26 '22 at 23:14
  • Does [VS Code Pylint highlighting the whole function with blue underline on missing function/class docstring](https://stackoverflow.com/questions/71117478/vs-code-pylint-highlighting-the-whole-function-with-blue-underline-on-missing-fu) answer your question? – wwii Jul 26 '22 at 23:16
  • blue is the range of a problem matcher item – rioV8 Jul 26 '22 at 23:43
  • great @wkl You provided the answer I needed exactly – Mahmoud Saad Jul 27 '22 at 03:42
  • using a variable name `string` that is also a possible class/type name is bad practice – rioV8 Jul 27 '22 at 07:41
  • @rioV8 added all the errors that were in the code in the answers – Mahmoud Saad Jul 27 '22 at 09:52

1 Answers1

0

Thanks to the commenters I learned How to read what's wrong which is by hovering over the underlined stuff.

It turns out they were all linting problems or warnings from the linter

I did see here how to disable this but this wasn't explaining what was the source or the reason for that.

Finally I know it and can trace and fix linting issues

Errors were due to snake_case function naming. classes and naming having no docstrings. and, operations without white spaces around it ex "==" instead of " == ".

Mahmoud Saad
  • 107
  • 1
  • 10