spot7.org logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories

Syntax error in for-loop


You have problems with indentation and colons. Specifically, each for statement needs a colon at the end, just before the following indented block of code.

Also, all code within a block needs to be at the same level of indentation. In your code, the last two lines are indented two extra characters. Here is the fixed code:

def grayScale(source):
    # Note indentation
    for y in range(0,height): # Note a colon here
        for x in range(0,width): # And here
            r = getPixel(getRed(source))
            g = getPixel(getGreen(source))
            b = getPixel(getBlue(source))
            average = (r + g + b) / 3
            newColor =
makeColor(average,average,average)
            setColor = newColor

# Your code...

Make sure to read about flow control in Python.


Categories : Python

Related to : Syntax error in for-loop
Rails+ActiveAdmin - filtering with ransacker throws an error PG::SyntaxError: ERROR: syntax error at or near ","
So I found the solution: First, I've changed my filter in admin/account.rb from filter :by_active_projects_eq to filter :by_active_projects_in, :as => :string This approach resulted in correct SQL generation, "accounts"."id" IN ('e4d247ec-e64d-4e8a-996a-4d73ccb11257', 'bcb8fa61-4a53-4b45-8954-8fb6ae328365', '93d670b6-7b8f-4c27-91cc-e0f44c137114') After that I also had to cha

Categories : Ruby
PHPBB Parse error: syntax error, unexpected '}' overall_header.html.php
Actually this is very simple error you are talking about. This should be solved by yourself. Use PHP Syntax Checker or other tools for this.

Categories : PHP
Parsing error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';'
You started the echo string with double quotes and the src=".." and alt=".." have double quotes, so you will need to use single ' or escape it with "

Categories : PHP
Getting Uncaught Error: Syntax error, unrecognized expression
This is happening because u1@g.com is not a valid value for an element's ID, so jQuery is unable to parse your selector. From the HTML4 spec: ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods ("."). The solution is to use a valid value for your ID. See also

Categories : Javascript
Android : Sqlite error - (1) near "null": syntax error
As mentioned, you need to assign values to the public static Strings in the ContactDB class. You should also make them final, to prevent them from being accidentally modified. public static final String con_id = "con_id"; public static final String short_name = "short_name"; public static final String first_name = "first_name"; public static final String last_name = "last_name"; public static fin

Categories : Android
Recently Add
Overriding save method vs Model Method?
function encrypt file - input & output to same file in python
urllib.error.URLError:
python if statement fails to compute compound logic
referencing sphinx generated Python docs from YAML file
Subclassing datetime64
filter view from url parameter with an intermediate model?
How to stream twitter mentions with tweepy?
How to space out rows and columns in Python Tkinter
Python: Using BeautifulSoup to save content to CSV
Python - Take parts of a txt file and put them in another txt
Python socket send doesn't send the whole string
Python: prime test
How to import one day old logs
Appending filters to django models
Python: parsing .xls file failed with both xlrd and pandas
writing pandas dataframe columns to csv rows staggered
parse_args doesn't seem to understand json arguments
Django ORM, get data
Pygame, keep jumping and glitching through the "ground"
Is it possible to import a class defined inside a function?
How to handle a variable number of nested for loops?
Boolean expression with strings
Object duplicated when using processing.Manager?
What is the syntax of PBS job limit directive
python 3.x overwrite previous terminal line
Deploying django app. on heroku (gunicorn, wsgi issue)
How can I create an "ID" column in one dataframe based on the index of another dataframe?
PIL Module Error
pandas.read_html returns only one table
© Copyright 2017 spot7.org Publishing Limited. All rights reserved.