I am trying to form a string using a list.
If the list only has a single element e.g.
l =  then the string should be
If there are multiple elements e.g.
l = [10,20,30] then the string should be
I tried but it always appends extra
, at the end.
"".join("%s," % x for x in l)
10,20,30, for the above lists.
Just use the following:
','.join(str(n) for n in l)
Answered By – Vadim Landa
Answer Checked By – David Goodson (BugsFixing Volunteer)