Skip to content
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

mad_libs Correct but not displaying Correctly #932

Open
alieana008 opened this issue Oct 24, 2024 · 1 comment
Open

mad_libs Correct but not displaying Correctly #932

alieana008 opened this issue Oct 24, 2024 · 1 comment

Comments

@alieana008
Copy link

I've completed the mad_libs function in Lesson 9 and when compared with the correct answer (mad_libs-correct.R) it is identical. However, when you run it, it says it is correct but it doesn't actually display the provided arguments within the printed text. See below:
Screenshot 2024-10-24 094433

Since it says this is correct, I'm not stuck or anything, but I am intrigued as to WHY it isn't actually displaying the text. With only a few lessons under my belt, I don't understand R well enough to know why this is happening or how to fix it, or similar issues I may come across, in the future. I'd appreciate any responses if someone has an answer, and it would be nice if the lesson were fixed to ensure no one else encounters this issue in the future.

@brendensm
Copy link

Your code does match the answer given and that is why you are getting the correct response. The key difference here is that you are passing in each argument as unnamed.

The solution is based around the idea that we can index certain values by name (get the value of "place" by using args[["place"]]). However, this relies on the argument submitted to be assigned that name.

You could see this by adding print(place) to the end of your function. If you do this, you will see a null value printed if your arguments are left unnamed. The function is working as it should because it returns nothing into the final pasted sentence.

If you adjust your code to the following, you should see the expected printed result: mad_libs(place = "Rockport", adjective = "many", noun = "fish")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants