-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Solution #3150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Solution #3150
Changes from 5 commits
ab24fac
f2d4ff3
79f6467
22135be
560da1f
ad7e0eb
279bc17
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,30 +1,25 @@ | ||
| name: Test | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: | ||
| - "master" | ||
| on: [pull_request, push] | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout repo | ||
| uses: actions/checkout@v2 | ||
| - name: Checkout code | ||
| uses: actions/checkout@v3 | ||
|
|
||
| - name: Set Up Python 3.8 | ||
| uses: actions/setup-python@v2 | ||
| - name: Set up Python | ||
| uses: actions/setup-python@v3 | ||
| with: | ||
| python-version: 3.8 | ||
| python-version: '3.x' | ||
|
|
||
| - name: Install pytest and flake8 | ||
| - name: Install dependencies and testing tools | ||
| # Installing app dependencies (from requirements.txt) and the pytest framework | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install -r requirements.txt | ||
| pip install pytest | ||
|
|
||
| - name: Run flake8 | ||
| run: flake8 app/ | ||
| - name: Run tests | ||
| run: pytest tests/ | ||
| # This command runs pytest, which should now be installed. | ||
| run: pytest | ||
|
|
||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,16 @@ | ||
| def count_occurrences(phrase: str, letter: str) -> int: | ||
| # write your code here | ||
| pass | ||
| """ | ||
| Count occurrences of a letter in a phrase (case insensitive). | ||
| :param phrase: The phrase to search within. | ||
| :param letter: The letter to count occurrences of. | ||
| :return: The number of occurrences of the letter in the phrase. | ||
| """ | ||
|
|
||
| # First, convert the phrase and the search letter to lowercase. | ||
|
||
|
|
||
| phrase_lower = phrase.lower() | ||
| letter_lower = letter.lower() | ||
|
|
||
| # Use the built-in .count() method | ||
|
||
|
|
||
| return phrase_lower.count(letter_lower) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function is missing a docstring. The task description requires a docstring that explains the function's purpose, parameters, and return value. Please add one as shown in the example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
)