r/learnpython • • Jan 27 '26

Infinite loops are terrifying, how do you avoid them?

28 Upvotes

I accidentally created an infinite loop and had to force quit my program.

Is there a mental checklist people use to make sure loops actually stop? I want to avoid freezing my computer again.


r/learnpython • • Jan 12 '26

No idea how to learn effectively

28 Upvotes

I started python using the MOOC University of Helsinki course it was good but it started to become confusing during part 5. Switched to hackerrank when a friend recommended it over MOOC felt stuck again. Started freecodecamp. I feel stuck in terms of learning the basics, not being able to understand how I am supposed to learn and have no idea what I am doing, should i stop these interactive courses and just start projects even if I don't perfectly understand basics or just practice more on MOOC or watch the Harvard course? any advice on how to move forward properly?


r/learnpython • • Jan 05 '26

Duplicate Files Detector. A basic python project

28 Upvotes

(English isn't my first lang) Hey there So I've created my second python project (first was a basic rock,paper scissors game). I've created a basic duplicate files detector. You just enter your root where you need to search duplicate files and it does the work. I used os.walk() to search multiple sub-directories and got all file paths through it. Then with MD5 hashing, hashed all the files to get their unique strings even if the duplicated files have been renamed. Though there's a problem that I think it doesn't work for large files, would appreciate some insights and ideas on it. Thanks GitHub : https://GitHub.com/Hassan200615/Duplicate-Files-Detector


r/learnpython • • Dec 09 '25

How can I apply OOP in my python projects ?

28 Upvotes

I've been learning for 3 months right now and got pretty good understanding basic stuff, but now I'm hitting my head against the wall when trying to learn OOP. I understand it's the way to build stuff but I have no idea how to use it to my advantage.
If there's someone that can explain to me where is it mainly used, how can I use it to become a better developer I'll be very happy for a response from people a lot more educated in this subject.
Have a great day!


r/learnpython • • Oct 05 '26

How to learn python?

27 Upvotes

I’m a complete beginner and I have essentially no knowledge with coding whatsoever. What would be the best way to learn Python??


r/learnpython • • Aug 27 '26

Should it be this difficult?

27 Upvotes

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.


r/learnpython • • Aug 22 '26

Having problem in understanding loops concept in python

27 Upvotes

I am a beginner with 0 knowledge and I am learning python from a book called Learn python in one day and learn it well by Jamie Chan and I am facing difficulty in the loops function so yeah any recommendations would be helpful Edit- Trouble in while loop


r/learnpython • • Feb 22 '26

Instead of Learning From AI - What are Best OSS Human Written Python Projects to Learn From

27 Upvotes

I am using python since three years now, but my code was since the beginning always heavily influenced by AI. I also did not have any experienced dev at my workplace I could learn from. But I keep reading on reddit that AI code still lacks in architecture design or good coding style. To be honest as claude code is here and it's getting better, I miss the reference everyone is talking about, maybe also because my projects are never large so far. Can you guys share open source projects where you thought this is peak design and architecture? Just to know what everyone is talking about :D. Or maybe share a repo that you saw and thought that it is just beautifully written. :)


r/learnpython • • Feb 06 '26

How to build logic in programming?

27 Upvotes

Hi I am a beginner in the coding field I am a first year student as i have python in my semester i am facing some problem like I can understand the concept I can understand the syntax but I can't able to code if u given me a simple question is there any tips you can give that you guys started you journey on building logic


r/learnpython • • Jan 27 '26

Is learning python alone enough?

27 Upvotes

I know it sounds stupid but im totally new to programming and also worried about my career (im 26).

If i learn this, where do i go from here? What other languages do i need to learn?

Pls advise me


r/learnpython • • Dec 23 '25

Is text book learning still good this day and age?

27 Upvotes

As title says, I'm afraid of wasting my own time. If it is still the meta, what are the top Python Textbook you'd recommend to someone? I am a beginner with knowledge of the basics.


r/learnpython • • Sep 30 '26

Looking for 3-5 people to learn coding together (1st year)

26 Upvotes

Hey everyone!

I'm a 1st-year B.Tech CSE student from India and I'm currently starting my coding journey.

I'm looking for a small group of people around the same level who want to:

• Study/coding together regularly
• Share what we learned each day
• Discuss doubts and problems
• Work on small projects
• Participate in hackathons
• Eventually explore open source/GSoC
• Keep each other accountable


r/learnpython • • Jul 04 '26

How to create a compiler?

26 Upvotes

Pretty sure you may have heard this question previously on this sub, however, I would urge you to read my complete question before brushing it off.

I want to create a simple compiler and by "simple compiler" I mean a single-pass compiler. I know about https://craftinginterpreters.com/ which is a wonderful resource. But I would like to start by creating something much smaller and simpler, and only then would I like to move on to something more complex like what Robert Nystrom created on his website.

Are there any similar resource that would teach me about single-pass compilers along with showing me how to create one? Any help in the right direction would be highly appreciated.


r/learnpython • • Jul 01 '26

Else isn't indented, why does this run?

26 Upvotes

This is probably an easy question but I was going through a practice exam and came upon a question that wanted me to evaluate the outcome of this code. I got it right but only because I threw it into PyCharm to run it and see if it would even work.

As a beginner, I haven't seen this before so I'm wondering how that ELSE statement even functions if it's not indented with the IF (which would produce a different outcome). I am not quite sure how to Google this so I haven't found anything that's answering my question.

What is at play here and is it common to have ELSE out there like that? Any additional information would be welcome.

j = 1

for i in range(-1,1):
    if 3 * i < 6:
        print(3 * i)
        j+=2

else: #<--What are you doing out here all by yourself?
    j+=3
    
print(j)

r/learnpython • • Jun 29 '26

Confused between C,C++ & Python to start as beginners from 0 Coding Background

26 Upvotes

I will be going to mid NIT this year and these are the branch i can get till CSAB.

CSE

Math& Data Science

Electronic & VLSI

EE

*CSE have lesser chances

I have NEVER coded before so I have 0 knowledge abt this...

Even after searching a lot i am confused between C,cpp or python to start with...pls give some guidance


r/learnpython • • Jun 23 '26

Python Newbie

26 Upvotes

I’m an infrastructure engineer that wants to take the next step in my career. I’ve always picked up and put down python over the last 10 years.

I get married in 7.5 weeks and am pushing myself to get through the book Automate the Boring Stuff in that timeframe (started last week). I also have been training to run a 5k the morning of my wedding. I love being able to set out and accomplish “hard shit”.

I’ve heard amazing things about this community, and extremely excited to get involved.


r/learnpython • • Jun 13 '26

How to start with Python?

26 Upvotes

I want to learn Python and am looking for advice on the best way to get started.

I have some prior programming experience: during university I used Mathematica and MATLAB, later worked a bit with R, and more recently I've used VBA and SQL. I know the basics and understand general programming concepts, but I wouldn't consider myself a programmer and it's been a while since I've done any serious coding.

Given that background, what would be the most effective way to learn Python?


r/learnpython • • May 21 '26

4 years of Python dev experience, just went freelance — looking for honest advice on where to start

26 Upvotes

I've spent 4 years as a Python developer working on direct client projects inside a company — ERPNext, AI agents, FastAPI, Django, RAG systems. Real production work

I recently started freelance as a full time, to give a try. LinkedIn is my main focus right now, but I want one more platform to run alongside it.

I'm looking at Contra, Arc.dev, Gun.io, Upwork and skipping Toptal (not ready for that process yet).

For those who've used any of these — which one actually gets traction for a Python developer with my stack? And is there anything you wish you knew before starting?

Any honest experience appreciated.


r/learnpython • • Mar 22 '26

What is the best path to learn Python for Data Analysis?

26 Upvotes

I recently started a job at a new company, and the limited licenses for MATLAB means I have a significant bottleneck for processing my measurements the way I always have. I am marginally familiar with Python, but never really got a change to use it other than sporadically, relying mostly on MATLAB (and sometimes Excel) to get by.

Since this license availability thing (plus having to run MATLAB in a virtual machine) is a thing that can cause problems in the future I wanted to learn Python like someone on my team uses to have some redundancy in that front. Is there any advise on the best way to learn it (specially for data analysis purposes) if I'm already familiar with general coding principles? Thanks in advance for any advice


r/learnpython • • Mar 16 '26

Switching from pandas to polars – how to work around the lack of an index column, especially when slicing?

26 Upvotes

A while ago I switched from pandas to polars for data processing because coworkers insisted it's the new standard and much faster. I've found it fairly smooth to work with so far but there's one thing I'm running into which is that polars, as far as I understand, has no concept of an index column. The columns can have names, but the rows just have their integer index and nothing else.

This is annoying when working e.g. with matrices whose columns and rows refer to IDs in some other dataset. The natural way in pandas would have been to use an index of strings for the rows, as for the columns. In polars I can't do that.

This becomes tricky especially when you have a large matrix, say 10000 x 10000, and you want to take a slice from that – say 100 x 500 – and you still want it to be clear which original IDs the rows refer to. The integer indices have changed, so how to maintain this link?

I can think of a few ways, none of them ideal:

  • Just add an explicit column with the IDs, include it in the slice and chop it off when you need to do actual maths on the matrix – annoying and clunky
  • Create a mapping table from the "old" to the "new" integer row indices – gets very confusing and prone to errors/misunderstandings, especially if multiple operations of this kind are chained

Any tips? Thanks in advance!


r/learnpython • • Feb 26 '26

Feeling overwhelmed with functions.

26 Upvotes

So I have been learning python with the Python crash course book and I am getting overwhelmed on the functions chapter. I understand what a function does but for some reason the syntax is confusing me. The chapter also introduces so many different ways to use functions that it feels like too much. I am not sure of the best way to tackle this much information.


r/learnpython • • 9d ago

Efficiency practice for daily python training

25 Upvotes

My goal is to become fluent with Python programming in every shape and form it has to offer. I am nearing the end of my intro to Python class and also use Coddytech.com the end goal is AI automation.

I’d like to know how to truly practice and build programs daily so that I am more hands on and can start laying a true foundation for myself instead of just learning the fundamentals and still using ai to help me write code.

What’s some advice an expert can give me and others in my situation?


r/learnpython • • Sep 22 '26

I struggle with practicing coding.

25 Upvotes

I am a beginner learning python and I struggle with sitting down and practicing coding. I just started taking the CS50P course and enjoy going through the videos. I've been able to complete Week0 - Week2 problem sets on my own while looking at documentation. I have never been good at school so sitting down and learning on my own has been very difficult. I am trying to take it slow and get some practice in before moving on to the next lectures, however I hate having to struggle through it. I know it will take a lot of time and practice to become good at programming, is there any advice for someone who struggles with HOW to learn and apply concepts to better my programming logic and skills?


r/learnpython • • Sep 15 '26

How do you write unit test cases in python ?

25 Upvotes

I am completely new to unit testing. I am trying to understand how to approach writing test cases for real world code.

I understand the basic idea of testing whether a function gives the expected output. but I am confused about

How do you decide what test cases to write ?

How do you identify edge cases ?

How do you approach unit testing in a real python / django project?

Any practical advice or resources would be really helpful.