Skip to content
Open
Show file tree
Hide file tree
Changes from 5 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
29 changes: 12 additions & 17 deletions .github/workflows/test.yml
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


17 changes: 15 additions & 2 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
def count_occurrences(phrase: str, letter: str) -> int:

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

)

# 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.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment and the one on line 14 must be indented to be part of the function's body. Currently, their lack of indentation breaks the function block and will lead to an IndentationError.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the same here


phrase_lower = phrase.lower()
letter_lower = letter.lower()

# Use the built-in .count() method

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this comment


return phrase_lower.count(letter_lower)
Loading