Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Dario-DC <105294544+Dario-DC@users.noreply.github.com>
  • Loading branch information
ilenia-magoni and Dario-DC committed May 10, 2024
1 parent 12831f5 commit d0ea5ea
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ dashedName: step-45

# --description--

When the loop reaches the letter `Z`, the sum `index + shift` exceeds the length of the string `alphabet`. At that point the `new_index` in `alphabet[new_index]` is higher than the last index in the string, which is not a valid index so there is an `IndexError` thrown, you can notice that the output in the terminal stops at the space immediately before the `Z`, the last `print` before the error is thrown.
When the loop reaches the letter `Z`, the sum `index + shift` exceeds the last index of the string `alphabet`. Therefore, `alphabet[new_index]` is trying to use an invalid index, which causes an `IndexError` to be thrown.

You can notice that the output in the terminal stops at the space immediately before the `Z`, the last `print` before the error is thrown.

In this case, the modulo operator (`%`) can be used to return the remainder of the division between two numbers. For example: `5 % 2` is equal to `1`, because 5 divided by 2 has a quotient of 2 and a remainder of 1.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ dashedName: step-53

# --description--

Restore the `caesar()` function call.
Right now, your code raises a `TypeError`, because the `caesar` function is defined with two parameters (`message` and `offset`), therefore it expects to be called with two *arguments*.

Right now, your code can't execute because the `caesar` function is defined with two parameters (`message` and `offset`) but it is called without *arguments*.
Calling `caesar()` without the required arguments stops the execution of the code.

Give `message` and `offset` values, by passing `text` and `shift` as arguments to the `caesar` function call.

Expand Down Expand Up @@ -47,6 +47,6 @@ def caesar(message, offset):
print('plain text:', message)
print('encrypted text:', encrypted_text)
--fcc-editable-region--
# caesar()
caesar()
--fcc-editable-region--
```
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ for i in text:

Python relies on indentation to indicate blocks of code. A colon at the end of a line is a signal that a new indented block of code will follow.

So, when no indented block is found after the final colon, the code execution stops and an `IndentationError` is thrown. This code will not show the output and instead show the `IndentationError`:
So, when no indented block is found after the final colon, the code execution stops and an `IndentationError` is thrown. This code will not show the output and instead raise an `IndentationError`:

```py
for i in text:
Expand Down

0 comments on commit d0ea5ea

Please sign in to comment.