I am trying to loop every element of a list, and append each element of the list to a string in the format like aa, bb, cc, dd, ee, ....
My loop is like this:
string = ""
for num in sorted(list):
string = "xyz" + "-" + str(list[num])
string = string + ", "
return string
The format it output is like xyz - 1, xyz - 3, xyz -6,
How can I end up without last comma in a format like
xyz - 1, xyz - 3, xyz -6
?