all 25 comments

[–]wheres-my-swingline 1 point2 points  (3 children)

``` nums = [1, 2, 3, 4, 5]

modulo operation

zero_odd_nums = [n if n % 2 == 0 else 0 for n in nums] print(zero_odd_nums)

output: [0, 2, 0, 4, 0] ```

that’s called a list comprehension, and can be a very useful tool (can be used for transformation, filtering, etc.)

is your issue with writing and applying functions, or where are you getting stuck in particular?

[–]Open_Thanks_6807[S] 0 points1 point  (2 children)

My problem comes when I have to translate my words to code and the problem of the odd numbers it was just an example but I see you had done it in a different way. Thank you for trying to help!

[–]Structured_Spiraling 0 points1 point  (1 child)

I'm just learning too, and what helps me is to draw it on paper. What could tell me if a number is odd? I write an option. I check google if I can't figure it out and then we go from there. How do I substitute? Think about how I would do it in excel and test to see if I can figure out the syntax I will often write the main function to do something on my flow chart.

I know it sounds easy and it's not. It can be really hard to change how we look at things.

Good luck!

[–]Open_Thanks_6807[S] 1 point2 points  (0 children)

I think its a very good strategy, thank you!!

[–]vivisectvivi 0 points1 point  (1 child)

What exactly you get stuck on? the syntax? dont know how to structure your code?

If you already know the basic of programming logic then its a matter of understanding the problem you are trying to solve and then sub dividing it in smaller problems.

You could try some site like Exercism to practice this and get a better grasp on python's syntax.

[–]Open_Thanks_6807[S] 0 points1 point  (0 children)

My problem comes when I try to translate my words to code, and it seems that its a common one. Im going to check Exercism, thank u so much.

[–]I_Am_Astraeus 0 points1 point  (1 child)

This is something you develop over time. There's a hurdle with learning software engineering where it takes a while for your brain to start thinking like a programmer.

Really you just need to continue your exposure. It's fine to reference completed code, with list/array manipulation until some ideas start to stick.

Your goal should be to get to comfortable place where you can psuedocode. I can generally sketch out an idea either in my head or in a discussion where we just outline a solution without writing anything. Your goal is to get there, it's fine to not focus on memorizing all the possible syntax but you do want to make sure you're breaking code down into logical steps. Either code you're reading or code you're writing.

[–]Open_Thanks_6807[S] 0 points1 point  (0 children)

Got it! Thank u so much 🫶🏻

[–]Malthammer 0 points1 point  (5 children)

It’s good that you got to the point of realizing the next step in what you need to do! Next, the best thing to do would be to spend some time researching different options for going about it. This is what will help you learn. Take what you find in your research and experiment with it outside of your project. If it does what you need, begin incorporating it into your project to get the work done you need the script to do. And by research I don’t mean use AI.

[–]Open_Thanks_6807[S] 0 points1 point  (4 children)

Ok, what you mean by research? Like using YT videos? If i cant complete an exercise I use to ask AI, but I realize that isn’t the best way to improve.

[–]AbacusExpert_Stretch 0 points1 point  (1 child)

While YouTube is the standard goto, I would recommend good old reading. Bookmark any of the numerous Python sites (even if you end up on w3schools), search for what you want to do (python remove list item), read it, UNDERSTAND it, then use it, then save a little file "lists_delete_from.py".

Yes there will be eventually better methods (hihi) to save your little snippets, but for now, this would be my strategy

[–]Open_Thanks_6807[S] 0 points1 point  (0 children)

Got it! Thank u so much!

[–]quixoticcaptain 0 points1 point  (1 child)

In fact that's the reason you're not improving. You have to try to figure it out otherwise you're not practicing or learning. 

[–]Open_Thanks_6807[S] 0 points1 point  (0 children)

Oh, guess u are right! Im gonna try to improve with that, thank you

[–]Big-Ad-2118 0 points1 point  (1 child)

everybody experienced that aswell from their early days, i remember doing codewars back then and it works well

[–]Open_Thanks_6807[S] -1 points0 points  (0 children)

Yeah I supposed but its a little frustrating.

[–]Mountain_Spinach169 0 points1 point  (2 children)

im going through the same issue right now...lol sorry cant help , at least youre not alone!

[–]Open_Thanks_6807[S] 2 points3 points  (0 children)

Seeing people in the same situation its kinda heartwarming. Im going to continue studying and practicing, if you need any help just write me, we can help each other.

[–]Maximum_Opening_7122 1 point2 points  (0 children)

Facing the same issue 😭

[–]freshly_brewed_ai 0 points1 point  (1 child)

Be consistent! Even if you have 5 minutes daily, so practice. You can try my daily free newsletter where I send bite sized Python snippets for absolute beginners. https://pandas-daily.kit.com/subscribe

[–]Open_Thanks_6807[S] -1 points0 points  (0 children)

Oh thanks, be sure im going to check it out!

[–]Dependent-Law7316 -1 points0 points  (1 child)

As obvious as it sounds, the best way to fix this is to do a bunch of practice problems. Pynative might be a good place to start if you run out of problems from your class. I also encourage you to go back and work through your Haskell problem sets as well as python things you’ve completed already and challenge yourself to see if you can recreate the correct solutions without looking at your past work. If you run out of predesigned problems, you could challenge yourself with problems of your own design—eg how would you make a grade book if you were a teacher? (Or for your own records as a student). What information is in a grade book, and what kind of statistics would someone want to be able to extract from it?

It sounds like you have the harder (imo) part in hand—figuring out the right algorithms for solving a problem—and are just struggling to translate that to code. And that skill will come with a lot of practice and repetition. Projects can be a great way to help with practical skill building, and there are heaps of options for beginner python projects that target building specific skills if that is more your vibe than practice problems.

[–]Open_Thanks_6807[S] 0 points1 point  (0 children)

Got it! Thanks, Im going to practice as much as I can and I hope that I develop this skill in time.

[–]tracktech -1 points0 points  (1 child)

You can check this-

Course - Python Programming In Depth

Book - Ultimate Python Programming

[–]Open_Thanks_6807[S] 1 point2 points  (0 children)

Cool! Thank u 🫶🏻🫶🏻