How to Put Fully Interactive, Runnable Code in a Medium Post

Code is meant to be interactive.

  1. Head to repl.it
  2. Write some code in your favorite language.
  3. Copy and paste the url for your repl into a Medium post.
  4. Publish the post to make the code interactive.
Interactive code. In a Medium article! (from repl.it).

Feel free to play around with the code above. This is a simple example, but you can create complex scripts for readers to run in many languages.

Notes

  • The code is only fully interactive after you publish
  • You can add packages, data files, or include multiple scripts in your repl
  • This does work on mobile although not perfectly
  • Each time the page is reloaded, the packages are installed

Besides embedding code in your articles, repl.it has a great discussion forum and interactive exercises to learn coding.

I welcome comments, feedback, or constructive criticism and can be reached on Twitter @koehrsen_will.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Published in Towards Data Science

Your home for data science and AI. The world’s leading publication for data science, data analytics, data engineering, machine learning, and artificial intelligence professionals.

Written by Will Koehrsen

Senior Machine Learning Engineer at Cortex Sustainability Intelligence

Responses (5)

What are your thoughts?