You can use *list
to send each value to print statement. With this approach, you don't have to worry about converting data to string.
With that, you can just give
mylist = ["A", "B", "C", 4, 5, 6]
print(*my_list, sep=", ")
The output of this will be:
A, B, C, 4, 5, 6
If you want to use the fstring, you can also try giving:
print(f'{*mylist,}')
The output of this will be:
('A', 'B', 'C', 4, 5, 6)
Note here that it prints with brackets ()
.
For more details about unpacking f-string, see the post on Stackoverflow here
Also please try to avoid naming variables as list
. It will get confusing later when you want to convert data to a list.
Example:
x = {1:5,2:10,3:15}
y = list(x)
print (y)
will convert dictionary x
to a list y