r/learnpython 3d ago

Seeking help with building logic while learning Python programming

I'm a DevOps engineer with 2 years of experience, and I come from a commerce educational background.

I've tried learning Python several times in the past, mainly when I was switching jobs and preparing for interviews. However, I ended up joining companies where Python wasn't really required or where nobody was particularly concerned about my Python skills.

Currently, I use AI to generate scripts for many of my daily DevOps tasks. My biggest concern is that I'm not able to build the logic myself or write the syntax from scratch. I often struggle with knowing when to use what.

The last time I seriously learned Python, I got up to lambda functions. That was about a year ago, and now I've completely forgotten a lot of the basics, including data types and syntax.

I want to properly learn Python because it's one of the most commonly mentioned skills in the DevOps/SRE job descriptions I see, especially for bigger tech companies. I've also lost a few interviews in the past because of my lack of Python knowledge.:

I'd really appreciate advice from people who have been through a similar situation. What worked for you?

23 Upvotes

10 comments sorted by

View all comments

1

u/Plenty-Midnight2075 2d ago

I think the mistake is treating Python as something you need to "finish learning" before you can use it.

Since you're already in DevOps, I'd learn it through the exact tasks you do every day. Pick small things like parsing a log file, reading JSON/YAML, calling an API, checking disk usage, renaming files, or automating some repetitive CLI workflow and write them yourself.

For building logic, force yourself to solve the problem in plain English first:

  1. What data do I have?
  2. What result do I want?
  3. What steps transform one into the other?
  4. Where do I need a loop, condition, function, etc.?

Then translate those steps into Python.

Also, don't worry about lambdas or advanced syntax right now. Get very comfortable with lists/dicts, loops, conditionals, functions, files, exceptions, modules, JSON, requests and subprocess. That's already enough to write a lot of useful DevOps automation.

I'd also change how you use AI. Instead of asking it to generate the entire script, write your own attempt first. If you're stuck, ask it to explain the next step or review your code rather than replacing it. Otherwise you're practicing prompting instead of programming.

Syntax comes back surprisingly quickly once you're writing code regularly. The logic part only really improves by struggling through lots of small problems yourself.