Write a Python program to Convert Set to Tuple


The program is converting a set val to a tuple s. The set val contains the elements 'T', 'u', 't', 'o', 'r', 'J', 'o', 'e' , 's'. First, the set val is printed along with its data type. Then, the set val is converted to a tuple s using the built-in tuple function. Finally, the converted tuple s and its data type are printed to the console.

Source Code

val = {'T', 'u', 't', 'o', 'r', 'J', 'o', 'e' , 's'}
print(val)
print(type(val))
 
print("\nConvert Set Into Tuple\n")
s = tuple(val)
print(s)
print(type(s))

Output

{'o', 'T', 'e', 't', 'r', 'J', 's', 'u'}
<class 'set'>

Convert Set Into Tuple

('o', 'T', 'e', 't', 'r', 'J', 's', 'u')
<class 'tuple'>