python - Return a string of country codes from an argument that is a string of prices -
so here's question:
write function return string of country codes argument string of prices (containing dollar amounts following country codes). function take argument string of prices following: "us$40, au$89, jp$200"
. in example, function return string "us, au, jp"
.
hint: may want break original string list, manipulate individual elements, make string again.
example:
> testequal(get_country_codes("nz$300, kr$1200, dk$5") > "nz, kr, dk"
as of now, i'm clueless how separate $
, numbers. i'm lost.
def test(string): return ", ".join([item.split("$")[0] item in string.split(", ")]) string = "nz$300, kr$1200, dk$5" print test(string)
Comments
Post a Comment