fork download
  1. #! /usr/bin/python3
  2.  
  3. switch = { 'key1':'value1',
  4. 'key2':'value2',
  5. 'key3':'value3',
  6. ...
  7. 'keyn':'valuen'
  8. }
  9.  
  10. def function1(data):
  11. #some code
  12. return value
  13.  
  14. def function2(data):
  15. #some code
  16. return value
  17.  
  18. ...
  19.  
  20. def functionn(data):
  21. if (data.find('something1') != -1):
  22. return value1
  23. if (data.find('something2') != -1):
  24. return value2
  25. ...
  26. if (data.find('somethingn') != -1):
  27. return valuen
  28. return "OK"
  29.  
  30. def Message(data):
  31. if (data.find('something1') != -1):
  32. return function1(data)
  33. elif (data.find('something2') != -1):
  34. return function2(data)
  35. ...
  36. elif (data.find('somethingn') != -1):
  37. return functionn(data)
  38. else:
  39. for key in switch:
  40. if (data.find(key) != -1):
  41. return switch[key]
  42. return 'OK'
  43.  
  44. ###########################################################
  45. #*********************************************************#
  46. ###########################################################
  47. data=input()
  48. msg=Message(data)
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Traceback (most recent call last):
  File "/usr/lib/python3.5/py_compile.py", line 125, in compile
    _optimize=optimize)
  File "<frozen importlib._bootstrap_external>", line 735, in source_to_code
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "./prog.py", line 7
    'keyn':'valuen'
         ^
SyntaxError: invalid syntax

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python3.5/py_compile.py", line 129, in compile
    raise py_exc
py_compile.PyCompileError:   File "./prog.py", line 7
    'keyn':'valuen'
         ^
SyntaxError: invalid syntax

stdout
Standard output is empty