Hey everyone! I'm back at it with CS50 after not making it too far last time, and I'm feeling really good about my progress this time around. I tackled the Readability assignment for Problem Set 2 (which is actually Problem Set 3), and tried to create a more advanced filter for text input. I realized that I could have simplified my code if I had utilized my `isrealPunct()` function earlier, but I chose not to refactor because I've learned so much already and I want to move on to the next assignment. Overall, I'm quite proud of how this turned out despite some frustrations along the way. Seeing all the green checks from `check50` made my day! Here's my code: [code snippet] If anyone has some critique or feedback, I'd really appreciate it! I've been learning a lot from the advice you all give.
2 Answers
Great work pushing the boundaries! A couple of things to consider: you don't need to pass the string length separately if you already have the string. Also, your function names could be clearer; using descriptive names can make your code self-explanatory. I noticed you're using single character variable names like `L` and `S`—try to avoid that outside of loops to maintain clarity!
You did a great job overall! Just a few suggestions: try to keep your variable names consistent, like ensuring `isrealPunct()` and `isRealPunct()` are uniformly capitalized. Also, adding some comments would help others (and maybe future you) to understand your logic better. For example, instead of `L` and `S`, use more descriptive names for your variables to clarify what they represent. Also, when you're checking multiple conditions, consider using `if-else` structures instead of consecutive `if`s; it makes the code cleaner. Keep pushing through!
Thanks for the tips! I can see how consistent naming helps readability. I'll definitely work on adding comments and organizing my logic more clearly in the future.
Thanks for the feedback! I agree, function names are key to understanding. I'll focus on improving that as I move on.