-4

I can't seem to figure out what's going on here. When I compile I get the does not match error.

It gives me the error about indentation mismatch on the line with bgB = 0;

def calcBG(ftemp):
"This calculates the color value for the background"
variance = ftemp - justRight;   # Calculate the variance
adj = calcColorAdj(variance);   # Scale it to 8 bit int
bgList = [0,0,0]                # initialize the color array
if(variance < 0):         
    bgR = 0;                    # too cold, no red         bgB = adj;                  # green and blue slide equally with adj         bgG = 255 - adj;     elif(variance == 0):            # perfect, all on green         bgR = 0;         bgB = 0;         bgG = 255;     elif(variance > 0):             # too hot - no blue
    bgB = 0;
    bgR = adj;                  # red and green slide equally with Adj
    bgG = 255 - adj;

so after updating the code with what @Downshift suggested and adding a few elifs i got the same thing def calcBG(ftemp): "This calculates the color value for the background" variance = ftemp - justRight; # Calculate the variance adj = calcColorAdj(variance); # Scale it to 8 bit int bgList = [0,0,0] # initialize the color array if(variance < 0):
bgR = 0; # too cold, no red
bgB = adj; # green and blue slide equally with adj
bgG = 255 - adj;
elif(variance == 0): # perfect, all on green
bgR = 0;
bgB = 0;
bgG = 255;
elif(variance > 0): # too hot - no blue bgB = 0; bgR = adj; # red and green slide equally with Adj bgG = 255 - adj;

ALSO: if someone could point out/explain to me exactly what i'm failing at that'd be great. because i can't seem to find my issue in this second portion. which is the same issue as the first.

  • 2
    no `;` in python, and indent after `def ...:` – Julien Jul 25 '16 at 05:33
  • 1
    @JulienBernu actually it is allowed to use semicolons there –  Jul 25 '16 at 05:47
  • 1
    If you're using Python 2, you may be mixing spaces and tabs. That's an error all by itself in Python 3. You might try running Python with the `-t` flag (which will make mixed whitespace give a warning) or `-tt` (which will make it an error). – Blckknght Jul 25 '16 at 06:11
  • 1
    Source view confirms you've mixed tabs and spaces. Stop doing that. – user2357112 Jul 25 '16 at 06:13
  • Running your code exactly as you've put it in the question runs fine, I don't get any formatting/indention or any errors, so it's not clear where the problem is. Are you running your code in an IDE or some kind of specialized code editor/formatter? As others mention, just be consistent with spacing, use the same number of spaces (usually 4 spaces per indent) OR one Tab indent, but the PEP-008 recommends just use all spaces, look at this here: [Code lay-out](https://www.python.org/dev/peps/pep-0008/#id16). And as stated above, whichever you choose, tabs or spaces, only use one NOT both. – chickity china chinese chicken Jul 26 '16 at 16:47

1 Answers1

-1

As the interpreter tells you your indentation levels are not consistent. Be sure to indent after first line of method definitions and if statements, With no changes to your code other than fixing indents:

def calcBG(ftemp):
    """This calculates the color value for the background"""
    variance = ftemp - justRight;   # Calculate the variance
    adj = calcColorAdj(variance);   # Scale it to 8 bit int
    bgList = [0,0,0]                # initialize the color array
    if(variance < 0):         
        bgR = 0;                    # too cold, no red         bgB = adj;                  # green and blue slide equally with adj         bgG = 255 - adj;     elif(variance == 0):            # perfect, all on green         bgR = 0;         bgB = 0;         bgG = 255;     elif(variance > 0):             # too hot - no blue
        bgB = 0;
        bgR = adj;                  # red and green slide equally with Adj
        bgG = 255 - adj;