Conversation
This function will capitalize the first character of a sentence or a word
|
Hey @mohammadreza490, TravisCI finished with status TravisBuddy Request Identifier: 6a13a0a0-ed71-11ea-b6ba-27fe84eba218 |
|
Hey @mohammadreza490, TravisCI finished with status TravisBuddy Request Identifier: 44f0ae20-ed72-11ea-b6ba-27fe84eba218 |
|
Hey @mohammadreza490, TravisCI finished with status TravisBuddy Request Identifier: ed65c340-ed74-11ea-b6ba-27fe84eba218 |
|
Hey @mohammadreza490, TravisCI finished with status TravisBuddy Request Identifier: c76f5420-ed75-11ea-b6ba-27fe84eba218 |
|
Hey @mohammadreza490, TravisCI finished with status TravisBuddy Request Identifier: f8fc9200-ed75-11ea-b6ba-27fe84eba218 |
|
Hey @mohammadreza490, TravisCI finished with status TravisBuddy Request Identifier: dd967390-ed76-11ea-b6ba-27fe84eba218 |
|
Hey @mohammadreza490, TravisCI finished with status TravisBuddy Request Identifier: 9e475eb0-ed77-11ea-b6ba-27fe84eba218 |
|
Hey @mohammadreza490, TravisCI finished with status TravisBuddy Request Identifier: 35c1c050-ed78-11ea-b6ba-27fe84eba218 |
Travis tests have failedHey @mohammadreza490, TravisBuddy Request Identifier: 86e10120-ed79-11ea-b6ba-27fe84eba218 |
Travis tests have failedHey @mohammadreza490, TravisBuddy Request Identifier: c0864740-ed7a-11ea-b6ba-27fe84eba218 |
Travis tests have failedHey @mohammadreza490, TravisBuddy Request Identifier: dfb51b90-ed7b-11ea-a128-157d03751755 |
Travis tests have failedHey @mohammadreza490, TravisBuddy Request Identifier: d7809fc0-ed7c-11ea-a128-157d03751755 |
|
@mohammadreza490 Thanks for your submission but in its current form it is just a demonstration of how-to-use the builtin str.capitalize() method. This repo focuses on building new algorithms, not on how-to-use existing ones. So here is an alternative approach to consider... Make a dict with the keys being string.ascii_lowercase and the values being string.ascii_uppercase. You could then use that dict to capitalize the first letter (if that letter is a key in the dict) without needing to use str.capitalize(). |
|
Hey @mohammadreza490, TravisCI finished with status TravisBuddy Request Identifier: 38f86760-edd2-11ea-a128-157d03751755 |
|
Hey @mohammadreza490, TravisCI finished with status TravisBuddy Request Identifier: 8ecec7a0-edd3-11ea-a128-157d03751755 |
|
Hey @mohammadreza490, TravisCI finished with status TravisBuddy Request Identifier: 1f0c2240-edd4-11ea-a128-157d03751755 |
Co-authored-by: Christian Clauss <cclauss@me.com>
|
Hey @mohammadreza490, TravisCI finished with status TravisBuddy Request Identifier: 315c2200-edd5-11ea-a128-157d03751755 |
Thank you for your comment. I changed the code as you suggested and sorry if I committed many changes because it's my first contribution. |
|
No problems ... Commit as many times as you want. We are experimenting to get the right solution. How could we streamline things using |
Co-authored-by: Christian Clauss <cclauss@me.com>
I think we can do something like this: |
|
Let's use the default parameter of dict.get(). Hint: define the dict first and then define first_character second. |
What about this? |
|
Nice! Now, can you shrink those last three lines into just one line? |
Well it seems it's possible: |
|
Looking great!! We need two more doctests: The empty string ("") will raise an error and a single lowercase letter ("a"). |
I fixed them by checking the length of the string. It returns the capital of a single letter and returns an empty string for "" |
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
Thanks for your help. I learned new things as well |
* Create capitalize.py This function will capitalize the first character of a sentence or a word * Update capitalize.py * Update capitalize.py * Update capitalize.py * Update capitalize.py * Update capitalize.py * Update capitalize.py * Update capitalize.py * Update capitalize.py * Update capitalize.py * Update capitalize.py * Update capitalize.py * Update capitalize.py * Update capitalize.py * Update capitalize.py * Update capitalize.py * Update strings/capitalize.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update capitalize.py * Update strings/capitalize.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update capitalize.py * Update capitalize.py * Update capitalize.py * Update strings/capitalize.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update capitalize.py * Update strings/capitalize.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update capitalize.py * Update capitalize.py Co-authored-by: Christian Clauss <cclauss@me.com>
Capitalization of the first character of a word or a sentence. It works like the capitalize() method of the strings in Python
Describe your change:
Checklist:
Fixes: #{$ISSUE_NO}.