Convert string to tuple Python

In this Python string tutorial, you will learn how to convert a string to a tuple in Python.

# Create a string
S = "AiHints"

# Convert string into tuple
T = tuple(S)

# Print tuple
print(T)

# Display the type of T
print(type(T))

Output:

('A', 'i', 'H', 'i', 'n', 't', 's')
<class 'tuple'>

Free learning resources: AiHintsCodeAllow

Leave a Comment

Your email address will not be published.