-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtools.py
More file actions
64 lines (50 loc) · 1.27 KB
/
tools.py
File metadata and controls
64 lines (50 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
from string import ascii_letters, digits
def classnum(text):
"""Return the words in a tweet, not including punctuation.
"""
for i in range(len(text)):
if text[i] not in ascii_letters:
if text[i] not in digits:
text = text[:i] + ' ' + text[i+1:]
return text.split()
def extract(dept, text):
text = classnum(text)
for i in text:
print('- course: '+ dept + '.'+ str(i))
def number_switch(num, up_to):
"""Takes a number, adds an "A" and a "B" onto it, up
another number of choice.
>>> number_switch(112, 114)
112A
112B
113A
113B
114A
114B
"""
while up_to >= num:
print('{0}A'.format(num))
print('{0}B'.format(num))
num += 1
def letter_add(num, end):
"""Adds one letter to the alphabet to the number of choice.
>>> letter_add(134, 'D')
134A
134B
134C
"""
for letter in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
if end == letter:
return
print('{0}{1}'.format(num, letter))
def consec_num(first, last):
"""Creates a column of every whole number between the first
and the last number.
>>> consec_num(5, 7)
5
6
7
"""
while first <= last:
print(first)
first += 1