You didn't say what language(s) or if you needed an offline solution.
Here are two online REPLs that I sometimes use on my phone when I have coding ideas on the train:
1. https://www.online-python.com/ - Python IDE
2. https://jsitor.com/ - JavaScript IDE