#!/bin/python
from functools import reduce
import sys
def adder(the_dict):
def concat(x,y):
nonlocal the_dict
if x and y:
return the_dict[x] + the_dict[y]
elif x:
return the_dict[x]
else:
return the_dict[y]
return reduce(concat,the_dict)
d={'a':'fuck ','b':'this ','c':'pluses '}
print('d is\n',d)
print(adder(d))
IyEvYmluL3B5dGhvbgpmcm9tIGZ1bmN0b29scyBpbXBvcnQgcmVkdWNlCmltcG9ydCBzeXMKCmRlZiBhZGRlcih0aGVfZGljdCk6CglkZWYgY29uY2F0KHgseSk6CgkJbm9ubG9jYWwgdGhlX2RpY3QKCQlpZiB4IGFuZCB5OgoJCQlyZXR1cm4gdGhlX2RpY3RbeF0gKyB0aGVfZGljdFt5XQoJCWVsaWYgeDoKCQkJcmV0dXJuIHRoZV9kaWN0W3hdCgkJZWxzZToKCQkJcmV0dXJuIHRoZV9kaWN0W3ldCglyZXR1cm4gcmVkdWNlKGNvbmNhdCx0aGVfZGljdCkKCmQ9eydhJzonZnVjayAnLCdiJzondGhpcyAnLCdjJzoncGx1c2VzICd9CnByaW50KCdkIGlzXG4nLGQpCnByaW50KGFkZGVyKGQpKQo=
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python2.7/py_compile.py", line 117, in compile
raise py_exc
py_compile.PyCompileError: File "prog.py", line 7
nonlocal the_dict
^
SyntaxError: invalid syntax