-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata_structures.py
More file actions
24 lines (19 loc) · 999 Bytes
/
Copy pathdata_structures.py
File metadata and controls
24 lines (19 loc) · 999 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
months= ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
print(months)
first_half= months[:6]
print(first_half)
q3= months[6:9]
print(q3)
greeting= "Hello there"
print('her' in greeting, 'her' not in greeting)
verse = "if you can keep your head when all about you are losing theirs and blaming it on you if you can trust yourself when all men doubt you but make allowance for their doubting too if you can wait and not be tired by waiting or being lied about don’t deal in lies or being hated don’t give way to hating and yet don’t look too good nor talk too wise"
print(verse, '\n')
# split verse into list of words
verse_list = verse.split()
print(verse_list, '\n')
# convert list to a data structure that stores unique elements
verse_set = set(verse_list)
print(verse_set, '\n')
# print the number of unique words
num_unique = len(verse_set)
print(num_unique, '\n')