The port of ticket_branch.py now splits the header at its first colon, so it has key and title ready. The next line builds the branch name, the part the review bot cares about most. It’s fix/ followed by the lowercased key and the first six words of the title, joined with hyphens.
In Python, that takes two lines and a call to split() you’ve written hundreds of times. JavaScript splits and joins text too, but its defaults aren’t Python’s, so the port passes every separator explicitly. JavaScript also puts join somewhere a Pythonista doesn’t expect. In this lesson, you’ll port both lines and build the branch the bot accepts.
Split the Title Into Words
The branch needs the title as a list of lowercase words, without the colon in “currency: EUR”. Here’s how the Python helper gets them, starting from the key and title that the first-colon split left:
key = "PAY-2291"
title = "Refund emails show the wrong currency: EUR shown as USD"
words = title.lower().replace(":", "").split()
branch = f"fix/{key.lower()}-{'-'.join(words[:6])}"
print(f"Branch: {branch}")
It prints Branch: fix/pay-2291-refund-emails-show-the-wrong-currency. That’s the line the port has to match.
The cleaning part carries over directly. You use .toLowerCase() where Python has lower(), and .replaceAll() where it has replace(), so every colon goes.