0Pricing
Mojo Academy · Lesson

Your First .mojo File

Create a file and print Hello, world.

Your First .mojo File is a free Mojo Academy lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Mojo Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

A File to Hold Your Code

Mojo programs live in plain text files. Each one ends with the .mojo extension so the toolchain knows how to compile and run it. 📄

Name It Clearly

Pick a short, lowercase name like hello.mojo. A clear file name makes it obvious what the program does when you come back later.

hello.mojo

The .mojo and .🔥 Twist

Mojo even allows the fire emoji as an extension, so hello.🔥 is valid too. Most people stick with .mojo for everyday work though.

Print Your First Line

The classic first program prints a greeting. In Mojo you use print, just like Python, to send text to the screen.

print("Hello, world!")

Code Goes Inside main

Your runnable code belongs in a function called main. Mojo looks for it as the starting point when the file runs.

def main():
    print("Hello, world!")

Indentation Marks the Block

Like Python, Mojo uses indentation to group code. The print line is indented under main, showing it belongs to that function.

def main():
    print("Hello, world!")

Save the File

Type the code in your editor and save it as hello.mojo. Nothing runs until you save, so this step matters before you try it.

Change the Message

The text inside the quotes is yours to edit. Swap it for a string like your name to make the program feel like your own.

print("Hello, Mojo learner!")

Strings Need Quotes

Any text you print must sit inside quotes. Without them Mojo treats the words as code and reports an error instead of printing.

print("This is text")

One File, One Program

This single .mojo file is a complete program. It has a main function with one job: greeting you. Small, but truly real Mojo.

Ready to Run

With hello.mojo saved, you have everything needed to run it. The next lessons show how to launch it from the command line.

Quick Check

You just created your first source file. What is the standard extension for a Mojo program?

Recap

You made a .mojo file, put a print call inside main, and saved it. That single file is a complete, ready-to-run Mojo program. 🎯

Frequently asked questions

Is the “Your First .mojo File” lesson free?

Yes — the full text of “Your First .mojo File” is free to read here on the web, and the Mojo Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Mojo Academy course, upgrade to CoddyKit PRO.

What will I learn in “Your First .mojo File”?

Create a file and print Hello, world. You practise Mojo Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Mojo Academy?

No prior experience is required. Mojo Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Your First .mojo File” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Mojo Academy lesson?

Yes. Every Mojo Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Your First .mojo File
  2. The main Entry Point
  3. Running with mojo run
  4. Exploring in the Mojo REPL
← Back to Mojo Academy