Created
October 18, 2018 03:23
-
-
Save elleryq/511c45756100a1b7be8bf4af124d77f8 to your computer and use it in GitHub Desktop.
Convert each words capital in string.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- coding: utf-8 -*- | |
| """Convert each words capital in string.""" | |
| from __future__ import print_function | |
| from argparse import ArgumentParser | |
| def convert_each_word_capital(s): | |
| """Convert each words capital in string.""" | |
| words = s.split(" ") | |
| capitaled_words = map(lambda x: x.capitalize(), words) | |
| return ' '.join(capitaled_words) | |
| def main(): | |
| """Main.""" | |
| parser = ArgumentParser() | |
| parser.add_argument('strings', metavar="S", type=str, | |
| nargs='+') | |
| args = parser.parse_args() | |
| for arg in args.strings: | |
| print("---") | |
| print("Before: {}".format(arg)) | |
| result = convert_each_word_capital(arg) | |
| print("After: {}".format(result)) | |
| if __name__ == "__main__": | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment