fork(1) download
  1. #!/bin/python
  2. from functools import reduce
  3. import sys
  4.  
  5. def adder(the_dict):
  6. def somerandomname(x,y):
  7. if x and y:
  8. return the_dict[x] + the_dict[y]
  9. elif x:
  10. return the_dict[x]
  11. else:
  12. return the_dict[y]
  13. return reduce(somerandomname,the_dict)
  14.  
  15. d={'a':'fuck ','b':'this ','c':'pluses '}
  16. print('d is\n',d)
  17. print(adder(d))
  18.  
Runtime error #stdin #stdout #stderr 0.02s 9016KB
stdin
Standard input is empty
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 '