It's been while since we posted! So,let's continue our project.
One of the essential data structures that we'll be using extensively is "SETS" in python.
Just for the essence,here's a quick look at it:
********CODE*********
my_list = []
my_set = set()
my_list.append('a')
my_set.add('a')
print(my_list) # Output: ['a']
print(my_set) # Output: {'a'}
my_list.append('b')
my_set.add('b')
print(my_list) # Output: ['a', 'b']
print(my_set) # Output: {'b', 'a'}
my_list.append('a')
my_set.add('a')
print(my_list) # Output: ['a', 'b', 'a']
print(my_set) # Output: {'b', 'a'}
********END**********
The reason behind using SETS over LISTS is elements in a set are unique and unordered.
By using this data structure,we can build our vocabulary for the application.
Learn more about SETS in python : https://docs.python.org/2/library/sets.html
See you guys in the next post!
-Kartik Mehetre
One of the essential data structures that we'll be using extensively is "SETS" in python.
Just for the essence,here's a quick look at it:
********CODE*********
my_list = []
my_set = set()
my_list.append('a')
my_set.add('a')
print(my_list) # Output: ['a']
print(my_set) # Output: {'a'}
my_list.append('b')
my_set.add('b')
print(my_list) # Output: ['a', 'b']
print(my_set) # Output: {'b', 'a'}
my_list.append('a')
my_set.add('a')
print(my_list) # Output: ['a', 'b', 'a']
print(my_set) # Output: {'b', 'a'}
********END**********
The reason behind using SETS over LISTS is elements in a set are unique and unordered.
By using this data structure,we can build our vocabulary for the application.
Learn more about SETS in python : https://docs.python.org/2/library/sets.html
See you guys in the next post!
-Kartik Mehetre
Good!
ReplyDeleteYay!
Delete