Ever got a concatenated API response string and needed to know what unique status values were present?
Scenario: our API returns a long string of status codes like "Automation and Python" and we need to extract every unique status that appeared, in the order it first showed up.
Here is the Python code:
api_response = "Automation and Python"
api_response = api_response.lower().replace(" ", "")
seen = ""
for ch in api_response:
if ch not in seen:
print(ch)
seen = seen + ch
No library. No regex. Just Python iterating through the string and tracking what it has already seen.
Why this matters as a Tester:
Not every API response comes in a clean, structured format. Sometimes you are dealing with concatenated strings, log outputs, or raw response bodies. Knowing how to extract unique values from messy string data is a practical skill that shows up more often than we would expect in real test automation work.
Top comments (1)
Some comments may only be visible to logged-in visitors. Sign in to view all comments.