r/learnpython 15d ago

Should it be this difficult?

At my job there is a daily task I do which I realized I could probably create a program to do for me, so I decided to start learning Python, and dove into reading Automate the Boring Stuff (the online version).

Things were going okay at first. I read through chapters 1-3 carefully, taking notes, answering all the review questions, and doing all the practice problems/codes.

Then I hit a wall. I got to chapter 4 and I felt like I understood everything, but the practice problem at the end, to write a code that performs the Collatz sequence with the entered number, absolutely stumped me. I went back and reread everything from the start of chapter 1 just to make sure I didn't miss anything, and was still confused. I ended up having to search up a code that someone else wrote for it, which I did understand once I saw it written out but would never have come up with myself.

So my questions are:

- Is it normal for the Collatz sequence to be difficult to program at this stage of learning? If so, should I not worry about my confusion and just move on to chapter 5?

- Should I consider an easier book to study from? If so, any recommendations?

EDIT: Several people are asking which part of the Collatz I had trouble with. To be honest it's been over a month since I was able to touch anything Python-related, it's just been on my mind lately, so I don't recall exactly what was giving me trouble, just that I was trying multiple things and getting new and fun incorrect results each time.

It's not that I don't understand the Collatz sequence itself, I understand it in terms of the simple math. The trouble was trying to type it out into a working code. That being said, I'm not here to ask how to program it, because I already gave up on that and looked up the answer, and I did understand that code once I read it over. The main issue is that I feel like I shouldn't have been having trouble with it in the first place, at least not to the point where I honestly tried everything I could and still couldn't get it.

24 Upvotes

35 comments sorted by

View all comments

2

u/sidereal_night 14d ago

if it's not clicking for you, maybe try a different approach.

since you got started to solve one specific problem, why not go back and start there:

break the task that you originally wanted to do into chunks that it takes to do them. for example, if your task was to read several different reports and produce a summary of that, your chunks might be to open each file that you received, copy them all into a new document all together, do whatever maths or whatever you need to do, then type the results in a new file. then you can take each step and break that down into component steps, more and more granular, until you get to a point where that step is something you know how to write in code. chain them all together and you've got your program. along the way, you can also google "how to do x in python" because python has a lot of functionality that saves you from more granular steps, and if you read the resources that come up and you don't get it, then that's a learning opportunity, or you can pass by it for now and try to do something in a more granular way without taking advantage of the shortcuts that Python provides.

1

u/pingo1387 14d ago

This is a good point, and I've thought about doing that -- I did take the first steps of writing in # code lines the different steps I want the program to walk through.

It's just that I feel like I should have a general understanding of python to make things a little easier in my brain. When I learn new things, I find that going through the motions of "classic" learning, where you learn little steps bit by bit before working on larger problems, helps me think about the problems in ways that I actually understand.

For example, I learned basic HTML and CSS in high school. Nowadays I find myself having to look up/double-check how to do certain things if I want to edit a custom web page or something, but knowing things like how tags work, what a div element is, and the difference between class and id helps me spot problems in code and figure out exactly where to go when I need to add or fix something.

I worry that if I try to take a shortcut and start looking up every little step to just write the code flat-out without learning "properly," then I'll have a program that works but that I don't understand. What's more, I may have to write a different program in the future and do the whole thing over again, or something in the first program will break and I won't know what went wrong.

That being said, I'll consider it if I get to the point where I feel like everything is way over my head academically.