Files
wehub-resource-sync dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 11:55:53 +08:00

1.3 KiB

id, title, challengeType, dashedName
id title challengeType dashedName
68b7687dded630607aceccb3 Challenge 49: CSV Header Parser 29 challenge-49

--description--

Given the first line of a comma-separated values (CSV) file, return an array containing the headings.

  • The first line of a CSV file contains headings separated by commas.
  • Remove any leading or trailing whitespace from each heading.

--hints--

get_headings("name,age,city") should return ["name", "age", "city"].

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_headings("name,age,city"), ["name", "age", "city"])`)
}})

get_headings("first name,last name,phone") should return ["first name", "last name", "phone"].

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_headings("first name,last name,phone"), ["first name", "last name", "phone"])`)
}})

get_headings("username , email , signup date ") should return ["username", "email", "signup date"].

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_headings("username , email , signup date "), ["username", "email", "signup date"])`)
}})

--seed--

--seed-contents--

def get_headings(csv):

    return csv

--solutions--

def get_headings(csv):
    return [h.strip() for h in csv.split(",")]