Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

convert set to list python time complexity

# Using dict.fromkey() convert list to set Python
# using the dictionary fromkeys() method.
# The only disadvantage of this method is we don’t get set in an orderly manner.


# a is defined list
a = [1,2,3,'seeker',3,7.5]

# Using dict.fromkeys() method
x = list(dict.fromkeys(a))
converted_set = set(x)
print(converted_set)

# Output:
# {1, 2, 3, 7.5, ‘seeker’}
 
PREVIOUS NEXT
Tagged: #convert #set #list #python #time #complexity
ADD COMMENT
Topic
Name
6+2 =