Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Contributing guidelines

## Before contributing

👏👏 Welcome to [examplehub/Python](https://github.com/examplehub/Python) ! Before sending your pull requests. Please make sure that you **read the whole guidelines**.

## Contributing

#### How to contribute
1. Fork the project to your github account & clone locally computer.
2. Create an upstream remote and sync your local copy before you branch.
3. Branch for each separate piece of work.
4. Do the work, write good commit messages, and read the `CONTRIBUTING.md`.
5. Push to your origin repository.
6. Create a new PR in GitHub.
7. Waiting to be review by the maintainers.

#### Code Style

#### Code Style
* Please follow [PEP 8](https://www.python.org/dev/peps/pep-0008/) Coding Style.
* Single letter variable names are old school so please avoid them unless their life only spans a few lines.
* Expand acronyms because `gcd()` is hard to understand but `greatest_common_divisor()` is not.
* Write `test unit` to test all your functions.
* [More details](https://docs.python.org/3/tutorial/controlflow.html#intermezzo-coding-style) about Code Style.

### Thanks for your contribution 😊
32 changes: 32 additions & 0 deletions strings/remove_whitespace.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
def remove_whitespace(original: str) -> str:
"""
>>> remove_whitespace("I Love Python")
'ILovePython'
>>> remove_whitespace("I Love Python")
'ILovePython'
>>> remove_whitespace(' I Love Python')
'ILovePython'
>>> remove_whitespace("")
''
"""
return "".join(original.split())


def remove_whitespace2(original: str) -> str:
"""
>>> remove_whitespace2("I Love Python")
'ILovePython'
>>> remove_whitespace2("I Love Python")
'ILovePython'
>>> remove_whitespace2(' I Love Python')
'ILovePython'
>>> remove_whitespace2("")
''
"""
return original.replace(" ", "")


if __name__ == "__main__":
from doctest import testmod

testmod()
41 changes: 41 additions & 0 deletions strings/reverse.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
def reverse(original: str) -> str:
"""
>>> reverse("abc")
'cba'
>>> reverse('1234')
'4321'
>>> reverse("cba321")
'123abc'
>>> reverse("")
''
"""
return original[::-1]


def reverse2(original: str) -> str:
"""
>>> reverse2("abc")
'cba'
>>> reverse2('1234')
'4321'
>>> reverse2("cba321")
'123abc'
>>> reverse2("")
''
"""
original = list(original)
i, j = 0, len(original) - 1
while i < j:
original[i], original[j] = (
original[j],
original[i],
)
i += 1
j -= 1
return "".join(original)


if __name__ == "__main__":
from doctest import testmod

testmod()