here is the sample for string which is inside a list
item_s=["hello - this","is - a","sample - task","i","want - to","do"]
can I have an output like:
item_s=["hello-this","is-a","sample-task","i","want-to","do"]
this is the code i tried to trim the spaces but it was showing error
amount=list(df["Price Range"])
def add_commas(s):
s1, s2 = s.split('-')
def process(s_part):
n, tmp_s = len(s_part), []
for i in range(n):
if i and not i % 3:
tmp_s.append(',')
tmp_s.append(s_part[n - i - 1])
return ''.join(tmp_s[::-1])
return process(s1) + '-' + process(s2)
def main():
amount=list(df["Price Range"])
return [add_commas(v) for v in amount]
main