On Sun, Jan 23, 2011 at 6:09 AM, Richard D. Moores <rdmoo...@gmail.com>wrote:

> Is a semantic error one that Python doesn't see as an error -- no
> error is raised; whereas syntax errors aren't errors unless Python
> sees them as "Syntax Error"s?
>
>
Yes:
http://en.wikipedia.org/wiki/Semantic_error

Here is a semantic error:

total = 0
for x in xrange(1,11):
     total = x       # Sums up x

The actual intent was to use += for total.

Another example

# Sums up numbers 1-10 inclusive
total = 0
for x in xrange(1,10):
      total += x

Of course (x)range doesn't include the end index, so in both cases the
program would compile and execute, but neither would give the programmers
intended result.

HTH
-Wayne
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to