convert string to tuple python code example

Example 1: convert a tuple into string python

tuple_ = 1, 2, 3, 4, 5
str(list(tuple))

Example 2: python string to tuple

l = list('abcd')  	        # ['a', 'b', 'c', 'd']
l = map(None, 'abcd')       # ['a', 'b', 'c', 'd']
l = [i for i in 'abcd']	    # ['a', 'b', 'c', 'd']

import re               # importing regular expression module
l = re.findall('.', 'abcd')
print(l)                	# ['a', 'b', 'c', 'd']

Example 3: how to add strings in tuple in python

First, convert tuple to list by built-in function list().
You can always append item to list object.
Then use another built-in function tuple() to 
convert this list object back to tuple.
You can see new element appended to original tuple representation.

by tutorialspoint.com 

happy coding :D

Example 4: string to tuple python

string = "mystring"
tuple1 = tuple(string)
# ('m', 'y', ' ', 's', 't', 'r', 'i', 'n', 'g')

tuple2 = string,
# ("my string",)