Search code snippets, questions, articles...

Convert comma separated string values to tuple python

you can use the .split() function to convert comma-separated values string to list and then use the tuple() method to convert the list to a tuple.
fruits = "Apple,Mango,Orange"
fruit_list = fruits.split(',')
print( tuple(fruit_list) )
# -> ('Apple', 'Mango', 'Orange')
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place.
('Apple', 'Mango', 'Orange')
Was this helpful?