When to Look Up Solutions While Learning Python?

0
2
Asked By CreativeCoder99 On

I've been diving into Python and recently worked on a simple contact book project using dictionaries and lists. The goal was to let users specify how many contacts to add and then gather each person's name, phone number, and email. I figured out how to loop through the number of contacts, but struggled with nicely structuring the data so that the name was the key in a dictionary, while the phone number and email were its values. After searching around, I found you can create a nested dictionary with a single line of code, but I felt guilty for not figuring that out on my own. Should I have pushed through longer, or is looking things up acceptable? How do I know where to draw the line?

5 Answers

Answered By CodeCrusader77 On

It's a mixed bag! Practicing problem-solving on your own is valuable, but don't hesitate to check common solutions online when you're stuck. Set a time limit on how long you'll try to figure things out before consulting Google. Maybe give yourself around two hours? This way, you get the benefit of reasoning through issues while not getting bogged down in trivial matters that have simpler answers already out there.

CreativeCoder99 -

I really like this approach. Thanks for the advice!

Answered By DebuggingDiva23 On

Honestly, it's totally fine to look things up instead of grinding through it forever. This is about learning efficient coding practices, and leveraging documentation is part of the process. There's no merit in sticking to a sub-par solution just for the sake of figuring it out alone.

ByteSizedBrain -

I feel that! Finding that balance can be tricky.

CreativeCoder99 -

But where do you draw the line on whether to keep trying or just look it up?

Answered By SWEJourney9 On

There's absolutely nothing wrong with looking things up while learning. In my experience as a software engineer, I Google things almost daily—often for basic syntax or functions I forget! Embrace using the vast resources out there. Just a heads up, your nested dictionary approach might complicate things when it comes to changing details like phone numbers. It's simpler to have your dictionary structured like { name: { 'phone_number': number, 'email': email } } for easier access and less hassle down the line.

Answered By NerdyNovice56 On

Wait until you encounter classes! They can make your code much neater. The struggles you're facing now are just stepping stones. Remember, looking things up is part of the learning journey, and you clearly put in the effort before seeking help!

Answered By CuriousDev42 On

Don't sweat it if you looked up the answer! It's normal to get a bit stuck on things when you're learning the basics. Once you see how to do it once, it becomes second nature in the future. Instead of complicating matters, try using two separate dictionaries—one for phone numbers and another for emails. It simplifies things and avoids the messiness of nested dictionaries in this case. Think about how you'd add another field later too; complexity can escalate quickly!

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.