Compare commits
No commits in common. "billy" and "master" have entirely different histories.
@ -1,12 +1,2 @@
|
|||||||
def titlecase(string, exceptions):
|
def titlecase(string, exceptions):
|
||||||
words = string.lower().split(' ')
|
pass
|
||||||
new_words = []
|
|
||||||
for word in words:
|
|
||||||
if word in exceptions:
|
|
||||||
new_words.append(word)
|
|
||||||
else:
|
|
||||||
new_words.append(word.capitalize())
|
|
||||||
|
|
||||||
return ' '.join(new_words)
|
|
||||||
|
|
||||||
print(titlecase('the quick brown fox jumps over the lazy dog', ['jumps', 'the', 'over']))
|
|
||||||
|
@ -1,15 +1,2 @@
|
|||||||
def remove_duplicate(string):
|
def remove_duplicate(string):
|
||||||
last = ''
|
pass
|
||||||
dups = ''
|
|
||||||
new_string = ''
|
|
||||||
for char in string:
|
|
||||||
if last == char:
|
|
||||||
dups += char
|
|
||||||
else:
|
|
||||||
new_string += char
|
|
||||||
last = char
|
|
||||||
|
|
||||||
|
|
||||||
return new_string, dups
|
|
||||||
|
|
||||||
print(remove_duplicate("balloons"))
|
|
||||||
|
@ -12,9 +12,3 @@ def get_totatives(num):
|
|||||||
|
|
||||||
def totient(num):
|
def totient(num):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
assert( compute_divisors(60) == [1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30, 60] )
|
|
||||||
assert( sum_of_divisors(60) == 168 )
|
|
||||||
assert( divisor_count(60) == 12 )
|
|
||||||
assert( get_totatives(30) == [1, 7, 11, 13, 17, 19, 23, 29] )
|
|
||||||
assert( totient(30) == 8 )
|
|
@ -1,15 +1,2 @@
|
|||||||
def word_stats(filename, n):
|
def word_stats(filename, n):
|
||||||
words = open(filename).read().replace('\n', '').lower().split()
|
pass
|
||||||
words = [''.join(e for e in w if e.isalpha()) for w in words]
|
|
||||||
out = {}
|
|
||||||
for word in words:
|
|
||||||
if word in out.keys():
|
|
||||||
out[word]['count'] += 1
|
|
||||||
else:
|
|
||||||
out[word] = {'count': 0, 'word': word}
|
|
||||||
|
|
||||||
out = sorted(out, key=lambda x:x[0])
|
|
||||||
|
|
||||||
return out
|
|
||||||
|
|
||||||
o = word_stats('article.txt', 5)
|
|
Loading…
x
Reference in New Issue
Block a user