Chrome Extension

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. Check how cool is the tool
Output
('Apple', 'Mango', 'Orange')
Was this helpful?
0 Comments
Join Devsheet Ask a Question