In [10]:
old_string = "hello"
new_string = ""
for i in xrange(len(old_string)-1, -1, -1):
    new_string += old_string[i]
    
assert old_string[0] == new_string[-1]
assert old_string[-1] == new_string[0]

In [11]:
"hello"[::-1]


Out[11]:
'olleh'

In [ ]:
class Node():
    left nul


In [1]:
def extendList(val, list=[]):
    list.append(val)
    return list

list1 = extendList(10)
list2 = extendList(123,[])
list3 = extendList('a')

print "list1 = %s" % list1
print "list2 = %s" % list2
print "list3 = %s" % list3


list1 = [10, 'a']
list2 = [123]
list3 = [10, 'a']

In [5]:
def eL(val, new_list=[]):
    new_list.append(val)
    return new_list

print eL(10)
print eL(123,[])
print eL(10)


[10]
[123]
[10, 10]

In [11]:
def func():
    new_value = 1
    return new_value
    
func(10)


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-11-784a9cd90710> in <module>()
      3     return new_value
      4 
----> 5 func(10)

TypeError: func() takes no arguments (1 given)

In [12]:
def multipliers():
    return [lambda x : i * x for i in range(4)]
    
print [m(2) for m in multipliers()]


[6, 6, 6, 6]

In [23]:
[l(1) for l in [lambda x : i * x for i in xrange(4)]]


Out[23]:
[3, 3, 3, 3]

In [25]:
[2 * x for x in [i for i in xrange(4)]]


Out[25]:
[0, 2, 4, 6]