Mar-18-2018, 03:52 PM
Mar-18-2018, 03:57 PM
Have you tried removing the comma from your code? Not the one separating the arguments for the print call, but the one inside the quotes?
Mar-18-2018, 04:09 PM
No because I want the commas to separate the list of my values but I just don't want the last comma
Mar-18-2018, 06:46 PM
(Mar-18-2018, 04:09 PM)mp3909 Wrote: [ -> ]No because I want the commas to separate the list of my values but I just don't want the last comma
print()
is only for display as it return None,so no way to save that list.If you want a list that's comma separated.
>>> list(range(10)) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> [i for i in range(10)] [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> # To a string with comma >>> ','.join([str(i) for i in range(10)]) '0,1,2,3,4,5,6,7,8,9'
Mar-18-2018, 08:00 PM
You can also do this
>>> for i in range(9): ... print(i, end=',') ... else: ... print(9) ... 0,1,2,3,4,5,6,7,8,9