#!/bin/python
from functools import reduce
import sys
def adder( the_dict) :
def somerandomname( x, y) :
if x and y:
return the_dict[ x] + the_dict[ y]
elif x:
return the_dict[ x]
else :
return the_dict[ y]
return reduce ( somerandomname, the_dict)
d= { 'a' :'fuck ' , 'b' :'this ' , 'c' :'pluses ' }
print ( 'd is\n ' , d)
print ( adder( d) )
IyEvYmluL3B5dGhvbgpmcm9tIGZ1bmN0b29scyBpbXBvcnQgcmVkdWNlCmltcG9ydCBzeXMKCmRlZiBhZGRlcih0aGVfZGljdCk6CglkZWYgc29tZXJhbmRvbW5hbWUoeCx5KToKCQlpZiB4IGFuZCB5OgoJCQlyZXR1cm4gdGhlX2RpY3RbeF0gKyB0aGVfZGljdFt5XQoJCWVsaWYgeDoKCQkJcmV0dXJuIHRoZV9kaWN0W3hdCgkJZWxzZToKCQkJcmV0dXJuIHRoZV9kaWN0W3ldCglyZXR1cm4gcmVkdWNlKHNvbWVyYW5kb21uYW1lLHRoZV9kaWN0KQoKZD17J2EnOidmdWNrICcsJ2InOid0aGlzICcsJ2MnOidwbHVzZXMgJ30KcHJpbnQoJ2QgaXNcbicsZCkKcHJpbnQoYWRkZXIoZCkpCg==
stdout
('d is\n', {'a': 'fuck ', 'c': 'pluses ', 'b': 'this '})
stderr
Traceback (most recent call last):
File "prog.py", line 17, in <module>
File "prog.py", line 13, in adder
File "prog.py", line 8, in somerandomname
KeyError: 'fuck pluses '