forked from course-work/week1
Update 01-title_case/title.py
This commit is contained in:
parent
f8006eb17c
commit
6839019f8a
@ -1,15 +1,7 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
def titlecase( string, exceptions ):
|
def titlecase( string, exceptions ):
|
||||||
word_list = string.lower().split(' ')
|
pass
|
||||||
|
|
||||||
for i, word in enumerate( word_list ):
|
|
||||||
if( word not in exceptions ):
|
|
||||||
word_list[i] = word.title()
|
|
||||||
|
|
||||||
word_list[0] = word_list[0].title()
|
|
||||||
|
|
||||||
return ' '.join( word_list )
|
|
||||||
|
|
||||||
assert( titlecase( 'the quick brown fox jumps over the lazy dog', ['jumps', 'the', 'over'] ) == 'The Quick Brown Fox jumps over the Lazy Dog' )
|
assert( titlecase( 'the quick brown fox jumps over the lazy dog', ['jumps', 'the', 'over'] ) == 'The Quick Brown Fox jumps over the Lazy Dog' )
|
||||||
assert( titlecase( 'THE vitamins ARE IN my fresh CALIFORNIA raisins', ['are', 'is', 'in', 'your', 'my'] ) == 'The Vitamins are in my Fresh California Raisins' )
|
assert( titlecase( 'THE vitamins ARE IN my fresh CALIFORNIA raisins', ['are', 'is', 'in', 'your', 'my'] ) == 'The Vitamins are in my Fresh California Raisins' )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user