This commit is contained in:
2023-09-25 14:36:26 -04:00
commit dcf0512e25
35 changed files with 1088 additions and 0 deletions

26
Title_Case/README.md Normal file
View File

@ -0,0 +1,26 @@
Title Transform
===============
Write a function that transforms a string into [title case](http://en.wikipedia.org/wiki/Letter_case#Headings_and_publication_titles).
This mostly means capitalizing only every first letter of every word in the string.
However, there are some non-obvious exceptions to title case which can't easily be hard-coded. Your function must accept, as a second argument, a set or list of words that should not be capitalized.
Furthermore, the first word of every title should always have a capital leter. For example:
```python
exceptions = ['jumps', 'the', 'over']
titlecase('the quick brown fox jumps over the lazy dog', exceptions)
```
This should return:
The Quick Brown Fox jumps over the Lazy Dog
An example from the Wikipedia page:
```python
exceptions = ['are', 'is', 'in', 'your', 'my']
titlecase('THE vitamins ARE IN my fresh CALIFORNIA raisins', exceptions)
```
Returns:
The Vitamins are in my Fresh California Raisins

7
Title_Case/title.py Executable file
View File

@ -0,0 +1,7 @@
#!/usr/bin/env python3
def titlecase( string, exceptions ):
pass
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' )