GithubHelp home page GithubHelp logo

Comments (11)

Dario-DC avatar Dario-DC commented on May 25, 2024
  • step 17

instead of text[0], pass text[0].lower() to .find()

I think this bit is already explicit, but I propose to change the instructions into:

Remove the last print() call. Then, instead of text[0], pass text[0].lower() as the argument to your .find() call and see the output.

  • step 42
    I think we can include something like "Remember to include the final colon" in specific hints.
    In my opinion, the idea of having a custom message for this case is not feasible, since missing a colon raises a SyntaxError, which can be caused by almost anything.

  • step 64
    I propose:

A ValueError is a built-in exception that is raised when an argument with the right type but inappropriate value is passed to a function.

The .index() method is identical to the .find() method but it throws a ValueError exception if it is unable to find the substring.

  • step 66
    I propose:

At the moment, your function prints some strings, but these values cannot be used by other parts of code to perform any actions.

For that purpose, you need to use a return statement:

def foo():
    return 'spam'

You need to write return followed by a space and the value that the function should return. Once the return statement is found, that value is returned and the execution of the function stops, proceeding to the next line of code after the function call. In the example above, the foo function returns the string 'spam'.

Remove the two print() calls from your function and return encrypted_text.

I'll think about step 13. I don't have any good ideas right now.

from freecodecamp.

a2937 avatar a2937 commented on May 25, 2024

About step 13, here's my thoughts on how to fix it. While it may not necessarily be a good idea, it can maybe be used to help come up with the right one. I'm leaning towards a full rewrite approach.

The first kind of cipher you are going to build is called a _Caesar_ cipher.  This kind of cipher involving shifting each letter of the message a certain number of characters over such that `A` becomes `D`, `D` becomes `G` , and so forth. 

We are going to start by finding the first letter of the string we want to parse in our `alphabet` variable. One way to do this is to use the `.find()` method on the string we're going to parse: 

\'\'\'
phrase = "Bacon" 
phrase.find('c')
\`\`\`

We are passing in a lowercase `'c'` character as a argument to the `find` function so we can find `'c'`'s zero-based position in the string. In this instance, the function will return `2`. At the end of the code, call `find()` on our `alphabet` string while passing in `text[0]` as the argument. 

from freecodecamp.

a2937 avatar a2937 commented on May 25, 2024

Regarding my changes to step 13, we don't actually need to know how many letters the message is being shifted by. We just need to know what it does. Secondly, I like my examples being completely self-sufficient such that I don't need to scroll all the way down to understand what's going on. Thirdly the less abstract, the better. Lastly, if we can; please keep all terminology the same in a single step. Flip-flopping between method and function isn't helpful when we need to explain that they're synonyms.

As an aside, I really wouldn't mind if we defined the terms in an really early beginning lesson set. Things like 'function' , 'variable' , 'attribute' , 'frontend', 'backend' , and what a programming language actually is. Some kind of introductory lesson to what FreeCodeCamp has to offer.

from freecodecamp.

Dario-DC avatar Dario-DC commented on May 25, 2024

please keep all terminology the same in a single step. Flip-flopping between method and function isn't helpful when we need to explain that they're synonyms.

I see your point, but .find() is a method, and we should call it a method, although there's no huge difference.

For step 13 I propose:

The first kind of cipher you are going to build is called a *Caesar* cipher. You are going to use the `.find()` method to find the position in the alphabet of each letter in your message. A method is similar to a function, but it belongs to an object.

```py
sentence = 'My brain hurts!'
sentence.find('r')
```
Above, the `.find()` method is *called on* `sentence` (the string to search in), passing the `'r'` (the character to locate) as the argument. The `sentence.find('r')` call will return `4`, which is the index of the first occurrence of `'r'` in `sentence`.

At the end of your code, call `.find()` on your `alphabet` string and pass `text[0]` as the argument to the method.

A couple of sentences about the Caesar cipher should be added in a following step.

from freecodecamp.

samGreer avatar samGreer commented on May 25, 2024

Regarding Dario's first comment discussing Steps 17, 42, 64, and 66, I think everything looks good. The only issue I have is with the the rewrite of Step 64, in which I would swap the paragraphs. I think it makes more sense to define what a ValueError is after using the term. It's a minor correction and it may just be down to how my specific brain works. Other than that, I agree with all the changes, and I think they make for stronger lessons.

I'll read through the discussion about Step 13 and address that in a separate comment

from freecodecamp.

samGreer avatar samGreer commented on May 25, 2024

Regarding Step 13, I think it makes sense to split it into two steps. The first step will explain how .find() works and what a method is (I prefer Dario's example for this), and the second step will explain how the Caeser cipher works (I prefer Anna's example for this) and have the same instruction as the existing step. Put together, it would look something like this:

Step 13:

You are going to use the `.find()` method to find the position in the alphabet of each letter in your message. A method is similar to a function, but it belongs to an object.

``py
sentence = 'My brain hurts!'
sentence.find('r')
``
Above, the `.find()` method is *called on* `sentence` (the string to search in), passing in `'r'` (the character to locate) as the argument. The `sentence.find('r')` call will return `4`, which is the index of the first occurrence of `'r'` in `sentence`.

[New instruction to practice using .find(), such as "call `.find()` on `alphabet` and pass in `z` as the argument"]

Step 14:

The first kind of cipher you are going to build is called a _Caesar_ cipher.  This kind of cipher involves shifting each letter of the message a set number of characters over such that `a` becomes `d`, `d` becomes `g` , and so forth.

To implement this, you will use the `.find()` method discussed in the previous step. 

At the end of your code, call `.find()` on your `alphabet` string and pass `text[0]` as the argument to the method.

While I think the exact wording could use work, I like this better because it has one clear thing it is teaching in each lesson. It also ensures that the introduction and explanation of the Caesar cipher will be on the same step.

If there's a problem with splitting this step in two that I'm unaware of please let me know

from freecodecamp.

Dario-DC avatar Dario-DC commented on May 25, 2024

If there's a problem with splitting this step in two that I'm unaware of please let me know

I'm okay with adding a new step 👍 To wrap up:

  • step 13
    We are going to split this in two steps:
    new step 13
You are going to use the `.find()` method to find the position in the alphabet of each letter in your message. A method is similar to a function, but it belongs to an object.

```py
sentence = 'My brain hurts!'
sentence.find('r')
```
Above, the `.find()` method is *called on* `sentence` (the string to search in), and `'r'` (the character to locate) is passed as the argument. The `sentence.find('r')` call will return `4`, which is the index of the first occurrence of `'r'` in `sentence`.

At the end of your code, call `.find()` on `alphabet` and pass `'z'` as the argument to the method.

hints and tests should be updated too.

new step 14

The first kind of cipher you are going to build is called a *Caesar* cipher.  Specifically, you will take each letter in your message, find its position in the alphabet, take the letter located after 3 positions in the alphabet, and replace the original letter with the new letter.

To implement this, you will use the `.find()` method discussed in the previous step. Modify your existing `.find()` call passing it `text[0]` as the argument instead of `'z'`.
  • step 17
Remove the last `print()` call. Then, instead of `text[0]`, pass `text[0].lower()` as the argument to your `.find()` call and see the output.
  • step 64
    To add in between the existing paragraphs:
A `ValueError` is a built-in exception that is raised when an argument with the right type but inappropriate value is passed to a function.
  • step 66
At the moment, your function prints some strings, but these values cannot be used by other parts of code to perform any actions.

For that purpose, you need to use a `return` statement:

```python
def foo():
    return 'spam'
```

You need to write `return` followed by a space and the value that the function should return. Once the `return` statement is found, that value is returned and the execution of the function stops, proceeding to the next line of code after the function call. In the example above, the `foo` function returns the string `'spam'`.

Remove the two `print()` calls from your function and return `encrypted_text`.
  • the issue related with step 42 involves going through the cipher project and add "Remember to include the final colon." in specific hints, when necessary.

from freecodecamp.

samGreer avatar samGreer commented on May 25, 2024

Thank you Dario! I'll get started on a PR for step 42

from freecodecamp.

a2937 avatar a2937 commented on May 25, 2024

Out of curiosity, what is left to do here? It seems a little disorganized.

from freecodecamp.

samGreer avatar samGreer commented on May 25, 2024

Looking through the pull requests it looks like everything is sorted, however when I go to the freeCodeCamp website I'm not seeing the changed Step 13/14 (link here) so I'm unclear what's going on there. All the other steps look good to me

from freecodecamp.

Dario-DC avatar Dario-DC commented on May 25, 2024

It's all done, so I'm going to close this issue.
@samGreer the code has been updated but not deployed yet, I think.

from freecodecamp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.