STR Coding Club logo STR Coding ClubLearn to code, together
Club Projects

Build a Python Contact Book as a Club Group Project

Most club projects fall apart at the same moment: the confident coder finishes everything in one evening and the two newcomers spend the session watching.

Four students around a classroom table with two laptops showing a terminal menu, sticky notes with function names stuck to a whiteboard behind them

Most club projects fall apart at the same moment: the confident coder finishes everything in one evening and the two newcomers spend the session watching. A Python contact book fixes that, because it splits naturally into small, separate jobs that each make sense on their own and still click together into one working program.

I have run this project with groups of four to seven people, ranging from members who had never written a loop to a sixth former who already knew classes. Over three sessions of about 90 minutes, every group I ran it with finished a contact book that adds, searches, edits, deletes and saves contacts to a file. Here is how to set it up so that everyone writes real code.

What the Python contact book does

Keep the scope tight. The finished program runs in the terminal and shows a numbered menu:

  1. Add a contact (name, phone, email)
  2. List all contacts in alphabetical order
  3. Search by name
  4. Edit a contact
  5. Delete a contact
  6. Save and quit

Contacts live in a list of dictionaries while the program runs, and get written to a CSV file when the user quits. Next time the program starts, it reads that file back in. That one detail, data surviving a restart, is what makes beginners feel they built something real.

No graphical interface, no database, no classes in version one. Every one of those is a fine stretch goal, but adding them at the start is how a three week project becomes a six week one that nobody finishes.

Splitting the work by skill level

The trick is that each menu option becomes its own function, and each function can be assigned to a person or a pair. If your members are still shaky on functions, run a short warm up from our Python function exercises for beginners in the first 20 minutes.

JobDifficultyGood fit for
Menu loop and input handlingEasyComplete beginners, in a pair
add_contact and list_contactsEasyMembers who know lists
search_contactsMediumMembers comfortable with loops and if
edit_contact and delete_contactMediumMembers who can handle indexes
load_contacts and save_contacts with CSVHarderYour most experienced member

Before anyone writes a line, agree on the shape of one contact as a group and write it on the whiteboard. A contact is a dictionary with three keys: "name", "phone" and "email". Every function takes the contacts list as an argument. This five minute agreement is the single thing that makes the pieces fit later.

Running the three sessions

Session one: the skeleton

Spend the first 15 minutes on a shared planning sheet. Write each function name, what it receives and what it returns. Then the menu pair writes a while loop that prints the options, reads a number and calls a placeholder function that just prints "not built yet". By the end of session one, the program runs and every menu choice responds, even if most responses are stubs. Everyone else writes their function in a separate file and tests it with a hard coded list of three fake contacts.

Session two: real functions

Each person or pair swaps their stub for their working function. Do this one at a time on the projector, so the group sees each piece land. The search function is where the first interesting bug usually appears: searching "sam" does not find "Sam". Let the member find it, then show them that lowering both strings fixes it.

Session three: saving and polish

The CSV pair connects load and save. Python's built in csv module with DictReader and DictWriter keeps this to about 15 lines. Use the last 30 minutes for testing: one member tries to break the program on purpose with empty names, letters in the menu choice and duplicate contacts, while the others fix what breaks.

Bugs you will almost certainly see

  • Typing a letter at the menu crashes the program. Someone used int(input()) with no check. This is a good moment to introduce isdigit() or a simple try and except.
  • Deleting while looping skips a contact. Removing items from a list while iterating over it shifts the indexes. Build a new list instead, or loop over a copy.
  • The file is empty after quitting. The save function opened the file in write mode before the contacts were loaded. Order matters.
  • First run crashes because the file does not exist. Check with os.path.exists, or catch FileNotFoundError and start with an empty list.

Resist fixing these for members. Ask what the program did, what they expected, and which line runs right before the crash. Nine times out of ten the member finds it once they say it out loud.

Write each bug on a sticky note when it appears. By the end you have a wall of real debugging lessons that came from your own club's code.

A counter-take: do not start with a class

Some mentors argue that a contact book is the perfect excuse to teach object oriented programming, with a Contact class and a ContactBook class from day one. For mixed groups, I think that is the wrong call. Classes add a layer of vocabulary, self and __init__ and methods, before beginners have even seen their data move around. Half the room stops following.

Plain dictionaries let everyone print a contact and see exactly what it holds. Once version one works, refactoring it into a class is a brilliant follow up project for the stronger members, because they can compare the two versions and see what the class actually buys them.

Stretch goals for fast finishers

  • Validate emails by checking for one "@" and a dot after it.
  • Prevent duplicate names, or ask whether to overwrite.
  • Add a birthday field and a "birthdays this month" option.
  • Export contacts to a neat text table with aligned columns.

If this project goes well, you can scale the same split into a longer build. Our guide to planning a six week coding club project shows how, and the list of club projects that work with mixed skill levels has more ideas in the same spirit.

Frequently asked questions

How long does it take to build a contact book in Python?

A small group can finish a working terminal version in three sessions of around 90 minutes. A confident solo programmer can do it in an afternoon. Adding a graphical interface or database roughly doubles the time.

What Python skills do beginners need for this project?

The easiest jobs only need print, input, lists and a while loop. Search, edit and delete need for loops and if statements. File saving needs basic understanding of opening files, which the stronger member can explain to the group.

Should a Python contact book use a database or a CSV file?

For a first version, a CSV file is simpler and you can open it in any spreadsheet to check your data. SQLite is a great second step once the logic works, because it teaches queries without needing a separate server.

IA
Imogen Achebe

Imogen started a coding club at her school and now trains volunteer mentors. She writes about first steps in coding and projects that work for groups of mixed ability.

More posts by Imogen

More in Club Projects

01doorganico 084goad 3hot8 4465456 after5internprogram ahandfulofblessings ahmadpc ahomcybersecurity allodialresources annodex antiquesandperiodcollectibles aotc asianworldkashmir beedlectrics bloggertemplatefree bluefeatheragency bodyweightsolution campaign08blog carfixadvisor catstreetcollective cbstvsports cnfanspurchasing committeeof500yearsofdignityandresistance covertopsdjs cs-kaiyuangame cuestacomunicaciontotal cxoutlet dancebetgame deskgearhub destinyvillastay detectmagazine di33 diamondsteelbuildings donmo dyanadropship emarsysfinance emimattl escapechan eskitarih evautoplay everythingweddings-orlando farmzone feedviewerapp foxstudiosscratch gamevui123 gleasongrade greetingsday hacklabasu haskell iw-kaiyun jagoanproperti jilidskripsi joltbusinessfinance juegodepokergratis juegospucca kaeru-festival latestmehndidesigns lestanzediottaviano litemagazines localcommunityhero lustrsazan mariashebets menswheels newwebstechs1 nikkit ootheday oxigenvpn plurfitness prefetial probudgetcarpetcleaning psychicmrsmartin pyaten qvantor rejoignezlogis rexzbot riselayouts ruchin rwxqsgd5 sakaltime shibiaowang shop-bot skrtips spotlesshaven tetapatrium topselller uneplanteartificielle vipertechcr webtech1223411 wo-kygaming yamaha-mekar yeknava yoybuysheets zenunwa yamaha-mekar jilidskripsi ankertoto ankertoto ankertoto