The program is a demonstration of how you can convert a string into a set in Python. The initial string s is assigned the value "TutorJoes". The type of the string is then printed which is "str". Then, the built-in set() function is used to convert the string into a set. The newly created set is stored in the variable new. The elements of the set are unordered and have no duplicates, which are the unique characters of the string. Finally, the value and type of the newly created set new are printed, which shows that the string has been successfully converted into a set.
# create a string str s = "TutorJoes" print("String Value : " ,s) print("Type of string : " ,type(s)) # convert String to Set new = set(s) print("\nString Convert to Set : ", new) print("Type of String : ",type(new))
String Value : TutorJoes Type of string : <class 'str'> String Convert to Set : {'t', 'r', 'o', 'e', 's', 'u', 'J', 'T'} Type of String : <class 'set'>
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions