Build the FLAMES Game in Python (Beginner Project)
Put loops, strings, and conditionals together to build the classic FLAMES name game in Python, step by step, from scratch.

You've spent the last few lessons collecting parts: strings, loops, conditionals. Parts are boring on their own. So let's bolt them together into something that actually does a thing — a small program you can run, hand to a friend, and tweak. We're building FLAMES.
What we're building
FLAMES is a playground name game. You take two names, find the letters they have in common, and cross those out from both. Whatever letters are left over, you add up and get a single number.
Then you count that number out around the word FLAMES — F, L, A, M, E, S — and every time the count lands on a letter, that letter is eliminated. You keep going around the survivors until exactly one letter is left standing. That last letter is your "verdict":
- F — Friends
- L — Love
- A — Affection
- M — Marriage
- E — Enemy
- S — Siblings
That's the whole game. Clean the names, cancel the shared letters, count what's left, count out around FLAMES. Four steps, and you already know how to write every one of them. Let's do them in order.
Step 1: clean the names
People type names with capital letters, spaces, sometimes a stray dot. The game doesn't care about any of that: Rahul and rahul are the same name. So before we compare anything, we flatten each name down to plain lowercase letters and nothing else.
name1 = 'Rahul'
a = [c for c in name1.lower() if c.isalpha()]
print(a)
# ['r', 'a', 'h', 'u', 'l']That one line does three jobs. name1.lower() makes everything lowercase. Looping over the string hands us one character at a time. And c.isalpha() keeps a character only if it's an actual letter, so spaces and punctuation get dropped. What we end up with is a list of letters — which matters, because in the next step we need to remove letters one at a time, and lists let you do that.
Step 2: cancel the common letters
Now we've got two lists of letters, one per name. For every letter the first name shares with the second, we knock it out of both, once each. Share two as? Two as come out of each side.
a = ['r', 'a', 'h', 'u', 'l']
b = ['p', 'r', 'i', 'y', 'a']
for letter in a[:]:
if letter in b:
a.remove(letter)
b.remove(letter)
print(a, b)
# ['h', 'u', 'l'] ['p', 'i', 'y']r and a are in both names, so they vanish from each. Notice the a[:] — that's a copy of the list. We loop over the copy but edit the original, because changing a list while you're looping over the real thing skips items and gives you wrong answers. Loop the copy, edit the original. That's the trick that makes this correct.
Step 3: count what's left
Whatever survived the cancelling, we add up the leftovers: name one's remaining letters plus name two's.
a = ['h', 'u', 'l']
b = ['p', 'i', 'y']
count = len(a) + len(b)
print(count)
# 6len() gives the length of each list, and we sum them. Three plus three is six. That count is the number we carry into the final step — it's how far we step each time we count out around FLAMES.
Quick check
Which earlier concepts does the FLAMES game combine?
Step 4: map the count to a result
Here's the part that feels like real logic. We start with all six results in a list and count out around them, removing one each time, until a single result remains.
Think of the six words sitting in a circle. Starting from the top, you count count steps; wherever you land, that word is out. Then you start counting again from the next word, go another count steps, eliminate that one. Repeat until one's left. (If you've heard of the Josephus problem, this is exactly that.)
count = 6
results = ['Friends', 'Love', 'Affection', 'Marriage', 'Enemy', 'Siblings']
index = 0
while len(results) > 1:
index = (index + count - 1) % len(results)
results.pop(index)
index = index % len(results)
print(results[0])The while loop runs as long as more than one result is left. Each pass, (index + count - 1) % len(results) walks count places around the circle — the % len(results) is what wraps you back to the start when you run off the end, so it stays a circle. results.pop(index) removes whoever you landed on. The second % len(results) keeps the index in range after a removal, which matters when you eliminate the very last item in the list. When the loop ends, one result is left, and that's the answer.
Tip
Build this one step at a time and run after each step. Get cleaning working, run it. Add cancelling, run it. Don't type all four steps and then go bug-hunting blind — you won't know which step broke it. One step, one run.
There's one edge case worth handling. If the two names have the exact same letters, cancelling leaves nothing on either side, count is 0, and counting out by zero steps would just spin forever. So we catch that: if count is 0, we call it Friends and move on. No infinite loop.
The full program
Here it is, all four steps wired together. The names are hardcoded so you can run it right now; edit them and hit Run to FLAMES anyone you like.
Run that and rahul + priya comes back Marriage. Change the names, run again, get a different verdict. That's a complete program — input at the top, logic in the middle, an answer at the bottom.
Recap and what's next
You just built a real thing from scratch. You cleaned strings down to letters, looped to cancel the shared ones, used len to count the leftovers, and ran a while loop with a conditional to land on the final result. Every piece came from an earlier lesson — strings and loops doing the heavy lifting, conditionals making the call. That's what programming actually is: small known pieces, arranged to solve one specific problem.
Notice we wrapped the whole thing in a def flames(...) — a function. We leaned on that so the logic had a clean name and could be reused, but we haven't really explained what a function is yet. That's exactly where we go next: functions, the tool for packaging code you want to name, reuse, and stop rewriting.

Written by
Rhythm Bhiwani
Engineer and relentless builder, happiest reverse-engineering hard problems until they click.
Enjoyed this?
Tap the heart to leave some love.
Be the first to react
Comments
Join the conversation.
Loading comments…


