fork download
  1. #!/bin/python
  2. from functools import reduce
  3. import sys
  4.  
  5. def adder(the_dict):
  6. return reduce((lambda x, y:
  7. the_dict[x] + the_dict[y]
  8. #sys.stdout.write(
  9. #'***\n\n'+
  10. #'x is not None\n'+repr(x is not None)+'\n'+
  11. #'y is not None\n'+repr(y is not None)+'\n'+
  12. #' x: ' + repr(x) + ' y: ' + repr(y)+'\n***\n\n')
  13. if x is not None and y is not None else
  14. the_dict[x]
  15. #sys.stdout.write(
  16. #'***\n\n'+
  17. #'x is not None\n'+repr(x is not None)+'\n'+
  18. #'y is not None\n'+repr(y is not None)+'\n'+
  19. #' x: ' + repr(x) + ' y: ' + repr(y)+'\n***\n\n')
  20. if x is not None else
  21. the_dict[y]
  22. #sys.stdout.write(
  23. #'***\n\n'+
  24. #'x is not None\n'+repr(x is not None)+'\n'+
  25. #'y is not None\n'+repr(y is not None)+'\n'+
  26. #' x: ' + repr(x) + ' y: ' + repr(y)+'\n***\n\n')
  27. if y is not None else None)
  28. ,the_dict)
  29.  
  30. d={'a':'fuck ','b':'this ','c':'pluses '}
  31. print('d is\n',d)
  32. print(adder(d))
  33.  
Runtime error #stdin #stdout #stderr 0.01s 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 32, in <module>
  File "prog.py", line 28, in adder
  File "prog.py", line 13, in <lambda>
KeyError: 'fuck pluses '