I found this code from here to run python code from gedit as an external tool with a shortcut,
#!/usr/bin/env python3.5
import sys
exec(sys.stdin.read())
its working like charm. But i have a problem i am unable to run python3.6 using this script, i downloaded python3.6 using pyenv directory for python3.6 is
/home/user/.pyenv/versions/3.6.4
when i tried to change directory in script it says permissions denied.