Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

convert set to list python time complexity

# For Loop to convert list to set Python
# In this method, we use for loop to access each element of a list and
# add that element in a set by using add() function.


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

# set() to convert list to set
sample_set = set() # defining set
#using for loop
for i in sample_list:
    #adding i to b
    sample_set.add(i)
print(sample_set)

# Output:
# {1, 2, 3, 7.5, ‘seeker’}

# Time of Execution 0.00019580
 
PREVIOUS NEXT
Tagged: #convert #set #list #python #time #complexity
ADD COMMENT
Topic
Name
2+9 =