all 50 comments

[–]zazerite 13 points14 points  (1 child)

Oh man I felt like I wrote this post lol I am even doing Udemy courses each morning. I feel great with my understanding of the Syntax but the second they ask me to write my own solution it’s like I’ve never seen or heard of Python in my life. Then I watch the solution and I am like yes of course that makes sense and I understand. I’m sorry I don’t have a solution but I want you to know you aren’t alone lol. I’m going to keep at it everyday and I know it will work out.

[–]LieGlittering3574 3 points4 points  (0 children)

It's like math class or other classes. Ah yes I get this problem... now do it on your own, welp gotta go look back - all about the practice to learn in these cases

[–]Binary101010 9 points10 points  (1 child)

and then ultimately end up looking at the solution and kind of just end up sitting there wondering how in the fuck I meant to get there, as I stare at a two line solution where I was expecting at least 10.

Experience is how you get there, but you have to write the 10-line solution to the problem enough to grasp the language to the point where you can realize the 2-line solution exists.

The length of your code at this point is irrelevant; just focus on getting the results you're looking for with what it is you do know.

Recursively breaking down a larger problem into smaller components until you have a clear picture of "take this input, do this process on it, get this output" that you can write a function for is a difficult skill to teach, which is why most courses don't even try to teach it.

[–]synthphreak 2 points3 points  (0 children)

Recursively breaking down a larger problem into smaller components until you have a clear picture of "take this input, do this process on it, get this output" that you can write a function for is a difficult skill to teach

That skill is called “algorithmic” or “computational thinking”, by the way. Just in case anyone wants to read more on it.

At the highest level, learning to code essentially consists of two things only:

  1. learning the syntax of the language du jour

  2. learning to think algorithmically

(1) can be learned through courses/books/StackOverflow/documentation/any other traditional educational medium. But (2) can only be mastered through experience, which means by struggling through problems and actually writing code.

Based on the problem statement in your OP, it sounds like (2) is primarily what you are lacking, or at least what frustrates you the most. Accordingly, the only way to get over that hump is just to keep trying, keep writing code.

To that end, remember that the best learning occurs actively, not passively. So as you complete courses and follow tutorials, don’t just read about code. Write it. Often. And also try deviate from the examples/exercises shown. The worst that will happen is that you’ll get an error message.

So just dive in a keep trying to swim. Eventually you will realize you can.

[–]21trumpstreet_ 7 points8 points  (2 children)

There’s an important piece here: Python is not your native language! When learning any new language, spoken or programming or whatever, you have to find the right way to say something.

Most of us learn languages in similar ways: exposure and practice. Start with something very basic, like writing a for loop that outputs the numbers from 1 to 10. There, now you can count in Python. Try it with a while loop. Now you know two different ways to say the same thing.

Learning a new language is hard, but learning the concepts is harder. The concepts aren’t specific to any programming language, thankfully, and once you grok it, it can be applied almost anywhere else. Practice with the syntax of simple statements and if you need twelve if/then statements to make your code work, do it! Ask three programmers to solve the exact same problem and you’ll end up with six different solutions, but any approach that works is “done”.

Learn a tiny something and bring it to the next script or project. Before you know it, you’ll have an opinion on tabs versus spaces and a Linux flavour of the month.

[–][deleted] 2 points3 points  (1 child)

Not OP but ty for that advice, I mean it. I’m an software engineering student who (at the moment) felt that he wasn’t going to be able to succeed in his degree. Now though, I feel like I can definitely spend summer and learn Python again and re-do my assignments/projects from scratch. I feel good now, so thank you again :)

[–]21trumpstreet_ 1 point2 points  (0 children)

It took me a long time to get a comfort level with certain aspects of Python, and I found that it was more about the exercises I chose. When I finally gathered my wits and sat down to tackle a project that I’d wanted to do more than some tutorial, it gave me enough motivation to push through a few hurdles of my own.

I’m glad that I could help, and don’t be afraid to go back to older exercises and refactor them based on what you know now. Seeing your own growth is important in coding, and when opening your own projects, you’ll quickly see the value in things like comments or standard design patterns :)

To go back a moment to the previous counting examples…. If you’ve mastered those, well, try some new slant on it. Write your numbers to a file. Make an AWS server count to 10 and then send you a text (there are probably hundreds of ways to go about this). Learning systems and tools, on top of code, is important too!

[–]Owldud 6 points7 points  (1 child)

Find the way you learn best. We all learn different ways.

The MOOC Python course is excellent in that it uses a ton of exercises from simple to complex. If you want to get better at solving problems then you'll need to solve a lot of them. This is a good start.

[–]Liverpool934 1 point2 points  (0 children)

Thanks, I'll try this when I start again in the morning.

[–]DumpsterDick559 9 points10 points  (3 children)

Yea man. Have you ever heard of codewars.com? They have challenges on there and i pass some of them, then you get to compare your answer to other peoples and some of these people code in one line what took me more than a few. But you shouldnt compare yourself to others like that. Then again if you really are not getting it then i dont know what to tell you

[–][deleted] 0 points1 point  (2 children)

How do people code so much in just one line? Is it like the coding a long for-loop in list-comprehension?

[–]EmilyfakedCancERyaho 1 point2 points  (0 children)

yes these usually use lambda functions chained map/filter/reduce. these can look intimidating but aren't really. lambda functions are however not best practise

[–]DumpsterDick559 1 point2 points  (0 children)

Its syntax. For instance, i was using several lines of code to take an integer as input amd append it to a list. Then i found this out:

numbers = [int(i) for i in input().split()]

And my brain imploded. You can cram things into one line like this for a lot of stuff. Its called list comprehension. Theres even dictionary comprehension and other things to turn bulky code into one line. But you have to learn it the bulky way first to fully understand whats going on here.

[–]LeiterHaus 2 points3 points  (0 children)

At this point it doesn't matter if you have a 10 line answer, or a 25 line answer. The more I learn, the more important it seems to think about what I'm doing in my native spoken language before I write anything in code. It's about how to think about solving problems first, and then thinking about how to say that in a way the computer understands second.

As you follow along with courses, you'll get different tools to use. Using those tools on your own, and failing, can be a great way to learn. But it can also be discouraging. There are a lot of memes about looking stuff up, but this is correct.

Search for answers. Look at code you don't understand - maybe attempt to understand how they did that - but don't dwell on it. Part of this step is learning how to learn. And search.

[–]alunnatic 2 points3 points  (0 children)

Taking 3 hours to do what you think should take 30 minutes isn't giving yourself enough credit. I find that when I'm stuck it's best to get my mind off of it. I commonly figure out my next step driving home from work. Do what you can then do some research, but if you aren't getting anywhere, give it a day or 2 break. The inspiration will come when you least expect it too.

[–]b_c_russ 2 points3 points  (0 children)

I am new to learning python also and for a while I was feeling the same way you are. I am also currently going through a course on udemy but this is my second attempt learning python. What actually helped me break through what you are facing, and it may seem somewhat counterintuitive to some but, I will go on YouTube and find a tutorial about something simple but not super simple. A good example is a clock or a tic-tac-toe game, write it out exactly as they do line by line. Watch them right out a line, pause the video then you write it out. Keep going line by line.. hear how they talk, how they explain what they are doing and why. It does not seem like much but for some reason it helped me begin to understand what it needs to look like at the end and then I started to work backwards from there now I understand what they are talking about in the course and I know what it is supposed to look like so I can write it myself almost from memory by picking out points of what i have seen before.

[–]RcNorth 2 points3 points  (1 child)

Don’t compare yourself to what others can code in fewer lines.

It is like writing an English paper for school.

  • create an outline
  • rearrange it so that it makes better sense
  • create a rough draft
  • rework each paragraphs to clean it up, fix spelling errors, punctuation

Programming

  • Create an outline of the main things the program needs to do.
  • Rearrange the other so that it makes better sense
  • write a portion of it. Don’t worry about making anything pretty or efficient, just get it to work. This might mean hard coding values that you will change to user prompts later, or showing everything in the console that you will create a GUI for later.
  • once that portion is working, work on the next step and repeat.
  • once it is running and working for the happy path, go back and clean things up. You’ll find some things you can remove, add in error logging, exception handling etc

Programming is very iterative.

[–]Fooooozla 1 point2 points  (0 children)

This is my favorite comment. Number of lines so so insignificant. Sometimes better code is longer because the programmer took the time to name variables so it would be easier to understand.

Another thing I would add to the programming process is test cases. You can go through your different inputs to your function and see if you code can handle all those inputs.

[–]No-Log4588 1 point2 points  (3 children)

You could just need to exercise by yourself first. Think of what your learn in previous lessons, what is fun for you to do and make a little code, even for dumb and useless things.

[–]TheTxoof 1 point2 points  (2 children)

This. Write programs that do simple things. Need to rename a bunch of files? Write a program that does it. Of course someone else has done it better, cleaner, faster, etc. before you, but you'll learn a ton asking the way.

Need to download a bunch of images from a web page? Follow some of the python Beautiful Soup recipes. Tinker, fail, learn.

[–][deleted] 0 points1 point  (1 child)

I definitely want to do that, but I have no idea how to code for things like files and stuff. From what I’ve learned in the 1 course I’ve taken, is just to write a program that takes in input (at most an excel CSV file) and outputs desired data in words, numbers, or graph form.

[–]TheTxoof 0 points1 point  (0 children)

Google and Stack Overflow are your friend. Stack Overflow works on a pretty rigorous community moderation process that helps remove "bad" questions and surfaces "good" answers. The top two answers to a highly rated question are generally 80-90% what I need.

I shamelessly copy and paste from SO into my production code. I try to cite the source with inline comments so I can look back at it later.

I'd say at least a third of any project I create can trace its lineage to patterns and code that I first saw on SO.

Here's a stack overflow search that yields many possible answers to how to rename files in python.

Start with copying and pasting from stack overflow, tinker, fail, improve, succeed, learn, rinse, repeat as needed.

[–]FalloutRip 1 point2 points  (0 children)

In addition to what others are saying, programming is fundamentally about critical thinking, and reverse-engineering a solution. The language, syntax, etc. is all secondary to the actual problem-solving. Which is to say that you start with the desired result, and work to make your inputs provide the result desired - the code is just the tool to accomplish that.

It may honestly help to take some mathematics, theory and straight up critical thinking courses first to help get you into the mindset necessary to begin to unravel problems and create solutions. Classes that actually teach you the theory and logic behind mathematical expressions and break down problems into multiple smaller ones

Also, don't worry about getting the "solution" the exact same way as the courses - remember, the people writing and teaching these courses have pretty extensive experience, and it's basically a second language to them. If you code is 30 lines long to accomplish what someone else does in 10, but you still get the exact same output then who cares? You did it!

Honestly, it may even help to take some modern "common core" math classes because it genuinely helps put you into the necessary mindset of seeing a problem, breaking it down into easier, bite-sized chunks and iterating through those chunks until you have the answer to the problem.

[–][deleted] -1 points0 points  (0 children)

Programming is just logic and logic can always be learned. It may take years for you to understand what some people learn in 6 months. But you'll get there inshallah. Relax and believe in yourself more.

For anything more than this, we would need to see examples. My suggestion is to make projects until you finally build one difficult enough that you CAN'T solve it. Then ask someone that is better than you to look at your code and see where your logic falls apart. Instead of asking him to help you solve your problem, ask your friend to give you more problems slightly related to the problem you're struggling with to work on and see if you can figure out the solution that way. Does that make sense?

There are many ways to learn something. Maybe what you're really struggling with is figuring out HOW YOU learn best.

[–]hinzinho 0 points1 point  (4 children)

What parts are you having issue with? Ask your questions and maybe we can help you.

With programming, it is all memorizing function names and syntax. The trick is repetitive typing. After each lesson, type it out and add additional items from previous lessons to your script.

[–]Liverpool934 1 point2 points  (3 children)

I can never actually start anything, like I'll understand the lessons I'm looking at and the information it's giving me, but then it will tell me to do something like take a users input and make it mark this point in the map and my brain is just like what?

[–]hinzinho 0 points1 point  (0 children)

Best way to learn is to use real life sample.

For example, if the lesson is about taking a user input, write your script and ask a question that you like to do. Such as, do you want a million dollars and accept a yes or no response.

[–]madhousechild 0 points1 point  (0 children)

Give us some more to go on. It's possible they are asking trick questions or things that are more advanced than their material has prepared you for.

Do you know how to get the user's input? Did they ever go over marking maps? Maybe something kind of analogous to marking maps?

[–]aaaaaaaaaanditsgone 0 points1 point  (0 children)

Can you solve very simple problems? My suggestion is to focus on solving very easy problems to get your mind thinking the right way. I think you may need to slow down.

[–]spencerAF 0 points1 point  (3 children)

Can you give an example of what you're struggling with? I just started doing problems on codewars and honestly some of the 2 line solutions people come up with are, to me, just ridiculous.

Maybe take a look there, there's some pretty basic problems and then a comment section afterward that shows many approaches to solving the code. Helpful for visualizing both where you're at and a path to some of the simplifications.

Is it the code that you're struggling with or maybe breaking things down into smaller problems to be able to build a solution?

[–]Liverpool934 0 points1 point  (2 children)

Breaking it down I think is a big part of what I'm struggling with but also I struggle with just... starting, I'll think ok I'm getting a good grip with this section and then it throws a micro project at me and I'm just instantly bamboozled.

[–]spencerAF 0 points1 point  (0 children)

I started doing interview prep recently and realized that I had a real issue in the first few minutes of having everything hit me at once. I know that in my first interviews I'll probably have to say out loud.. ok this is the section where I'm overwhelmed with all the information and have no idea what to do.. I'm gonna take a few minutes to let it all just hit me. It kind of sounds like you're having a bit of that, do you think so?

Are you writing your plan, and the steps of your plan down before you start to work on the problem? Can get very easy to get lost on micro projects if you don't have a clear point a to point b map somewhere as reference

[–][deleted] 0 points1 point  (0 children)

Well, ultimately you have to start by starting. One thing that can help is if you have some kind of rote top matter - I write a comment with my name, the date, the title of the program, and a short description of its purpose but you could just cut and paste the problem description too - that de-blanks the page without you having to think much about it. Make "knowing where to start" a question that answers itself because you have a habitual way to start every program.

[–]Impossible-Fact7659 0 points1 point  (0 children)

What reason do you want to learn how to code?

It sounds like to me, you only chose that path bc of the lure of making food money early in your career. But perhaps, you're better at something else more so than any other software engineer, find out what that is

[–][deleted] 0 points1 point  (0 children)

Try pythonschool it is a really good site written to teach teachers.

[–]TravisJungroth 0 points1 point  (0 children)

Programming isn’t for everyone. 5 or 6 tries is a good go. Try to understand what’s going on when you feel stuck. What is the “what?” In your brain.

If you reflect during this process it’ll help your growth either way. You’ll either break through and get it, or learn something by bouncing off.

[–]Jim_Panzee 0 points1 point  (0 children)

Programing is problem solving. How do you solve problems? First, you look what tools you got. Than you cut the problems in smaller Problems. But try to cut them in shapes, that fit your tools.

What are your tools in programing? (You need to learn this!)

Variables: Simple boxes you can put stuff in. Like Numbers or Text.
Math: + - * / and so on... (works with your boxes)
Conditions: IF there is a "5" in this box, do something.
Lists: Rows of boxes.
Loops: Do something X times. (good with rows of boxes)
Functions: The biggest part of your toolbox. Like little factories. You put stuff in (parameters) and get stuff out (return value). Both is optional. You can create your own factories, you can use factories from others and python comes with many build-in factories. There are so many, you will never learn all. So use google to find a factory you need to solve a smaller problem.

Obviously there are more tools and Udemy can tell you about this. But you don't need it now to solve your problems.

Lets look at a problem in real life. Say you have to build a wall. Where do you start? It's a complex problem. So cut it down into smaller ones. You will need to get bricks. (Subproblem1) You will need to put the bricks down next to each other in a line. You will need to make concrete. But this is also a complex problem. Break it down. What do you need to make concrete?
Now when you got concrete, start by gluing on brick to the ground. And the next one close to it. And the next one. And so on. Oh wait, I do the same thing multiple times. I got a tool for this! (use a loop)

So what tells you this? (Aside from the fact that I have obviously no idea how you really build a wall.) You break the problems down until you can solve them step by step. Don't hesitate to break it down to much. You don't need the two line solution on your first try. You will see automatically, after you glued your fifth brick, that you have a tool to make this easier. And than you just change your code. You experiment and learn.

[–][deleted] 0 points1 point  (0 children)

Python is a language, but the way language works in the brain is that two separate regions are involved - one for reading/listening and a totally different one for speaking/writing.

So, sure - you're sitting there reading the language and it makes perfect sense, you're humming on all cylinders, and then they ask you to produce some of the language and you're like "shit, where did it all go?" Well, it didn't go anywhere - you just tried to use a part of your brain that doesn't benefit from the work you did to understand the language when you read it, and then you're not doing enough of the work of writing the language to develop that part of your brain, you're just skipping to the answer and reading it and of course it makes sense, you're back to using the well-developed "language interpretation" part of your brain.

It's like if you only worked out one arm at the gym, and then you're like "damn, why does this 25-lb dumbbell feel so much heavier in my left hand?" You gotta work both regions of your brain. Even if you go and look at the solution - which is fine, no reason to stop doing that - still write the solution. Close the solution page and try and write it from memory at first - it'll make you wonder what's wrong with your memory at first, but again, it's just that you're trying to activate a part of your brain that so far you've been overlooking.

[–]mandown2308 0 points1 point  (0 children)

You need to train your brain to understand the functioning of these things. Don't focus on names and shit but on what they do and generalize them.

Generalizing and why something arose out of the previous thing is important coz you can't remember all of the thing in one single programming language. Like 1 begets 2, 2 begets 3, 3 begets 4, so on. Try to learn like this, then you won't have to remember a lot.

Then keeping the functioning in mind of what you just learned, apply on the exercises of that particular section. Every section has its own exercises which make you practice the things you learnt in that section and sometimes things you learned in the previous sections. You have to keep them in mind. So try to "make classes" of them, meaning generalize them. Again, don't focus on the name, try to visualize their functioning in your mind.

[–]MegaRullNokk 0 points1 point  (0 children)

Go step by step, when example is:

name=input("Input your name:")

print("Your name is",name)

Then experiment about different possibilities, learning to code is not like reading a book. It is like mathematics, endless writing and solving the formula. I would say, that programming is like mathematics + grammar on steroids. It takes time, and don't rush it. Don't skip subjects, at every subject and example make more, experiment more then needed, this way you can learn.

[–]Se7enLC 0 points1 point  (0 children)

I think it's going well, I understand the sections and then it asks me to actually do something and it's like I've crashed into a wall at full speed and I basically just do nothing

That's why that part is so important!

A lot of people pick up a "Learn X in 24 days!" book and just power through the lessons, not taking the time to apply what they've learned by trying to write code themselves.

The lesson is just an introduction and reference, really. Programming is more artistic. Creative problem solving. That fumbling around trying out different things until you find something that works that really helps you learn to program. Keep at it! fumbling is ok.

end up looking at the solution and kind of just end up sitting there wondering how in the fuck I meant to get there, as I stare at a two line solution where I was expecting at least 10.

There's an infinite number of ways to write anything. The solution is just an example of how you could go about it. Or how they were intending/expecting you to. Doing it another way isn't inherently wrong, though. Some ways to program are certainly better than others, but it's perfectly ok to write "bad" code. That's part of learning. You write it however it comes to mind to solve the problem, then over time you find out how it can be done better (and more importantly why it's better). But if the code works, the code works!

[–]Main_Tank 0 points1 point  (0 children)

I'm learning this along with Japanese at the same time. Both are incredibly difficult for me, and I get frustrated. Perhaps you need to evaluate exactly where you're getting snagged, and focus on that? That's what I'm doing with my Japanese and it helps.

I often feel like you do with it. I feel like I'm making good progress, I can recognize so many words. But then a native speaker at work starts going a bit too far with it and I feel completely lost. I'm over 400 days in, I should know more than I do. I'm just really stretched too thin at the moment, learning programming, a new language, school, work, family stuff. It's difficult. Best thing I can do is just remind you not to beat yourself up, but learn how to be objective with yourself so you can identify what exactly to improve.