The Palos Publishing Company

Follow Us On The X Platform @PalosPublishing
Categories We Write About

Create a flashcard system with CLI

Here’s a simple Python-based CLI flashcard system. It allows you to:

  • Add flashcards (question + answer)

  • Review flashcards

  • Save/load flashcards from a file

python
import json import os FLASHCARDS_FILE = "flashcards.json" def load_flashcards(): if os.path.exists(FLASHCARDS_FILE): with open(FLASHCARDS_FILE, "r") as f: return json.load(f) return {} def save_flashcards(flashcards): with open(FLASHCARDS_FILE, "w") as f: json.dump(flashcards, f, indent=4) def add_flashcard(flashcards): question = input("Enter question: ").strip() answer = input("Enter answer: ").strip() flashcards[question] = answer print("Flashcard added!") def review_flashcards(flashcards): if not flashcards: print("No flashcards to review.") return for question, answer in flashcards.items(): print(f"nQuestion: {question}") input("Press Enter to see the answer...") print(f"Answer: {answer}") input("Press Enter for next flashcard...") def main(): flashcards = load_flashcards() while True: print("nFlashcard System") print("1. Add flashcard") print("2. Review flashcards") print("3. Exit") choice = input("Choose an option: ").strip() if choice == "1": add_flashcard(flashcards) save_flashcards(flashcards) elif choice == "2": review_flashcards(flashcards) elif choice == "3": print("Goodbye!") break else: print("Invalid choice. Try again.") if __name__ == "__main__": main()

You just run this script in your terminal. It saves flashcards in a JSON file locally and loads them automatically next time.
Want me to extend it with categories, quizzes, or spaced repetition?

Share this Page your favorite way: Click any app below to share.

Enter your email below to join The Palos Publishing Company Email List

We respect your email privacy

Categories We Write About