← Courses

Python for AI — Beginner Foundations

Data Science

Tools · Lesson 66 of 76

Environment & secrets

Real programs often need secrets — an API key, a password — that must never be written directly in your code (anyone who sees the code would see the secret). Instead you keep secrets outside the code, in the environment, and read them at run time.

Python

Because no API_KEY is set here, it prints the fallback — and importantly, no secret is ever in the code itself. The next lessons show how to set these values properly.

Your turn: change the fallback text and run it again.

You’re reading for free. Sign in to keep your progress and earn a certificate when you finish.Sign in to keep my progress →