Code
Use a Code field for syntax-highlighted examples, algorithms, and programming questions. It displays code; it does not execute the program.
Add a code example
- Add a Code field to the deck template and choose its side.
- Open its gear and set Programming Language.
- Enter the code in the card editor.
- Preview the card and save it.
For example, put this Python snippet on Front and 6 in a Text field on Back:
Add a Note field for the explanation: sum adds the values in the list. The answer is authored by you; Flashnerd does not run the snippet to verify it.
Display settings
Use template settings for a consistent deck, or a card-level override when one example uses a different language.
Keep code readable
Choose a short snippet that tests one idea. With wrapping off, a long line may require horizontal scrolling; with wrapping on, indentation can be harder to follow on narrow screens. Preview on a phone-sized card before adding many examples.
Use Cloze Deletion when the task is to recall a missing text fragment. Code syntax highlighting alone does not hide answers.
Related: Field settings.