Oh my. Udacity is certainly *not* the best way to learn Python. They tend to try and keep it simple, but often this is to the detriment of readability. Here's an example from CS373 (most of the example code is like this):
if x2 >= 0 and x2 =0 and y2
Which could have been written like this:
if 0
Or another example:
next = open.pop()
x = next[1]
y = next[2]
g = next[0]
Which could just as easily be:
g, x, y = open.pop()
Hell, even
for i in range(len(delta)):
x2 = x + delta[i][0]
y2 = y + delta[i][1]
is nicer as
for dx, dy in delta:
x2 = x + dx
y2 = y + dy
And your example
if(a > 0) { return a + 1; } else { return a -1; }
==
return a + 1 if a > 0 else a -1
Udacity's approach is great for teaching theory, bad for teaching Python. If you want to write idiomatic Python, do some research on iterators, generators, functools, list unpacking, etc. Sorry if the code samples here screw up, but /.'s markup system blows hard.