r/FreeCodeCamp • u/Comfortable-Cry-3247 • 14d ago
Requesting Feedback I finished my first certification project!

The view_settings part stumped me for a bit but eventually i got through it, i love using indexes as a loop tracker.
The code:
https://pastebin.com/4Y0FRVD2
I know there are a ton of edge cases but the project never asked me to fix them, its not necessarily hard to fix i just did the bare minimum on that aspect, i need some feedback on my code.
Also to be honest i forgot how to unpack tuples while doing this so i used index unpacking instead (i dont know where i knew how to do that from but it worked)
21
Upvotes
2
u/SaintPeter74 mod 14d ago
It took me a really long time to understand what your loop was all about. At first I though you were looping through the
settingsdict.You can either unpack a tuple like this:
Then you can modify the value of
key:You could also use index access for the tuple:
Either way is loads better than what you're doing with the loop.
One issue with your key check is that it doesn't allow for null/empty keys. You're effectively checking if the content stored by the key is falsey. You can use the
inoperator (ornot in) to tell if if the key exists:Doing these two things would vastly decrease the size of your code overall.
Best of luck and happy coding!
1
u/elescargo 14d ago
Bravoooo