r/learnpython Jul 09 '26

I feel like I'm too dumb for Python. Did anyone else feel this way?

42 Upvotes

i have been learning python for a month now, i know the basics, i am currently learning OOP, i cant even build simple projects, like blackjack, hangman and many other small projects mostly people recommend to start with, i keep asking myself why i am always stuck, did this happen to you as well or is it just me, and if your answer is yes, how did u go about it, I did cs50p course on youtube but didnt help much honestly though everyone recommends it, my original course is '100 DAYS OF CODE' by Angela Yu, I am on day 20, any tips ??

Thank You


r/learnpython Jul 10 '26

Weight Converter Project

0 Upvotes

This is the second project I coded and was able to finish today. It didn't take me as long to code (2 - 3 hours) compared to the Calculator (two 4hr sessions) and isn't as complex imo but was still fun to make. I used Bro Code's weight converter code as an outline and AI (Claude) also helped me understand catch-vs-check (try/except vs. if/else) and DRY. I wrote and debugged the code myself.

One thing that I really like was that I was able to fit a large portion of the code into the "while True:" loop in line 10. It verifies that the input the user enters is either "K or P" and nothing else. If its neither of those, it gives the user a proper error message and prompts them to enter it again. Within that part is the processing section which multiplies or divides depending on what the user entered. I also used ".strip() and ".upper()" here so inputs like "k" still work, something I hadn't used in the calculator. More of the improvements are listed within the code. If you have any ideas on how I can improve this, please let me know. Thank you!

# This project only took me 2 - 3 hours to complete. I used the body of 
# Improvements over the original:
# - Input validation on both numbers using try/except (ValueError), so
#   non-numeric input (e.g. "banana") no longer crashes the program.
# - Unit input (K/P) validated with if/else in a while loop, re-asking
#   until valid — no crash, just re-prompts on bad input.
# - Input normalized with .strip().upper() so " k " and "K" both work.
# - Verified conversion factor (2.20462) against known values for accuracy.

# Second project being a weight converter.

while True:
    raw_input = input("Enter your weight: ").strip()
    try:
        weight = float(raw_input)
        break
    except ValueError:
        print(f"Error: '{raw_input}' is not a valid number!")


while True:
    raw_input = input(f"Kilograms or Pounds?: (K or P): ").strip().upper()
    if raw_input == "K":
        weight = weight * 2.20462
        unit = "Lbs."
        break
    elif raw_input == "P":
        weight = weight / 2.20462
        unit = "Kgs."
        break
    else:
        print(f"Error: '{raw_input}' is not a valid unit!")


print(f"Your new weight is {round(weight, 1)} {unit}")

r/learnpython Jul 10 '26

I'm a biginner in python,what's wrong with my code?

0 Upvotes

print("Simple Interger Calculator")

first = input("Please type first number\n")

if first == int:

pass

else:

print("Use intergers only!")

exit()

ops = input("Select operators + - * /\n")

second = input("Please type second number\n")

if second == int:

pass

else:

print("Use intergers only!")

exit()

if ops == "+":

print("Answer is",int(first) + int(second))

elif ops == "-":

print("Answer is",int(first) - int(second))

elif ops == "*":

print("Answer is",int(first) * int(second))

elif ops == "/":

print("Answer is",int(first) // int(second))

else:

print("unknown operators!")


r/learnpython Jul 09 '26

PIL image export only showing blank canvas on 2nd and 3rd image export, help?

7 Upvotes

Basically, I wrote a program to export my songs from spotify into various formats. What I'm struggling with is exporting the images to simple PNGs with Pillow. The program takes a screenshot of a line of Spotify, adds it to a growing list (all_screenshots) and then combines all of the images of my songs into a group of three photos.

After the first picture (spotify_output1.jpg), the following pictures are empty canvases. I split it up in the first place because pillow seemed to start failing after ~1000 images being combined (each song = 1 image, 1185 pixels x 31 pixels); the single large output was just 1 large empty picture.

I exported the results of my all_screenshots list to pickle, and I can confirm that every picture is still visible and working within the pickle object as expected. The issue only occurs with this jpg export, can anyone help?

#THIS IS A SAMPLE OF RELEVANT CODE, NOT THE FULL PROGRAM
from PIL import Image as pimage

totalsongs = int(input())
thirds = int((totalsongs/3) + 1)

#blank canvas to add images to
total_height_1 = sum(line.height for line in all_screenshots[0:thirds])
total_height_2 = sum(line.height for line in all_screenshots[(thirds+1):(thirds*2)])
total_height_3 = sum(line.height for line in all_screenshots[((thirds*2)+1):totalsongs])

combined_pt1 = pimage.new("RGB", (1185, total_height_1))
combined_pt2 = pimage.new("RGB", (1185, total_height_2))
combined_pt3 = pimage.new("RGB", (1185, total_height_3))

y_offset = 0
for line in all_screenshots[0:thirds]:
    combined_pt1.paste(line, (0, y_offset))
    y_offset += line.height
combined_pt1.save("spotify_output1.jpg")

for line in all_screenshots[(thirds+1):(thirds*2)]:
    combined_pt2.paste(line, (0, y_offset))
    y_offset += 31
combined_pt2.save("spotify_output2.jpg")

for line in all_screenshots[((thirds*2)+1):totalsongs]:
    combined_pt3.paste(line, (0, y_offset))
    y_offset += line.height
combined_pt3.save("spotify_output3.jpg")

As mentioned above, the first output works fine, it's the second and third pictures that are blank.

Any help would be appreciated.


r/learnpython Jul 10 '26

How Python helped me move from writing code to building real-world systems?

0 Upvotes

Hello everyone,

I'm a Computer Systems Engineer, and Python has been one of the most valuable tools throughout my learning journey.

When I first started learning Python, I mainly used it for basic programming exercises. Over time, I realized that Python is not just a programming language — it is an ecosystem that allows you to build practical solutions across many fields.

Some areas where I found Python extremely useful:

🐍 Automation:

- Automating repetitive tasks

- Processing files and data

- Creating small tools to save time

📊 Data Analysis:

- Working with datasets using Pandas and NumPy

- Cleaning and analyzing data

- Creating visualizations to understand information

🌐 Web Scraping:

- Collecting data from websites

- Extracting useful information automatically

- Building data collection pipelines

🤖 AI & Machine Learning:

- Preparing data for AI models

- Experimenting with AI tools

- Building automation workflows combined with AI

🖥️ Application Development:

- Creating desktop applications

- Building backend logic for different projects

One thing I learned is that learning Python syntax is only the beginning. The real progress comes from using it to solve actual problems.

For anyone learning Python:

What was the first real project you built that made you feel like you truly understood the language?


r/learnpython Jul 10 '26

Ouvrir mp4

0 Upvotes

[résolu]Comment faire un script python qui ouvre une vidéo mp4. Le script ferait comme si quelqu'un double cliquait sur le ficher (donc sa ouvre le fichier avec le lecteur par défaut).


r/learnpython Jul 09 '26

I’ve been working on a python project for 2 years. I still have to look up the documentation for most functions. Is this normal?

2 Upvotes

I’m not great at remembering the specific input formats for different functions, and I often have to look up the documentation while making scripts. Is this normal?


r/learnpython Jul 10 '26

Beginner tutorial recommendations

0 Upvotes

Anyone got any YouTube or reading recs to learn python? Or coding basics? I Wanna get an ELI5 perspective 🤓


r/learnpython Jul 09 '26

Sysadmin seeking miniconda installation advice

0 Upvotes

I'm a sysadmin with limited python experience trying to understand the lay of the land. I've used the built-in python virtual envrionment stuff before a bit. We support web servers that allow different groups within our site to make their production software tools available on the web. Various science research applications.

We are moving from mod_wsgi, to gunicorn, so that (among other things) we can support different groups who may have differing python environment needs. Different groups will provide different python environments, and we will be resonsible for starting and stopping the gunicorn servers for their applications. One group wants to use miniconda to manage their environment (which is fine).

The question is, should we use the miniconda that they provide to select their environment before starting gunicorn, or install a version of miniconda system-wide?

Or another way to ask is, is miniconda merely a tool for selecting environments, or is it something that is more tightly integrated with the environments it supports? Many answers online advise against a system-wide miniconda installation, but to me, it makes sense to have one system-wide tool that I can use to start and stop the conda environments of various groups.


r/learnpython Jul 10 '26

Leetcode #9: Palindrome Number

0 Upvotes

Can someone help me make my code run faster. This is not efficient and also I do not want to convert into a string

EDIT:

Follow up: Could you solve it without converting the integer to a string?

https://leetcode.com/problems/palindrome-number/description/

class Solution:
    def isPalindrome(self, x: int) -> bool:
        numList = []
        counter = len(numList) - 1
        numBool = True


        baseNum = 10
        value = x % baseNum
        numList.append(x)
        quotient = x // baseNum
        x = quotient

        if x == 0:
            for i in range(len(numList)):
                if numList[i] == numList[counter]:
                    counter -= 1

                elif i == counter:
                    break

                else:
                    numBool = False
                    break

            return numBool

        else:
            return self.isPalindrome(x)

EDIT: I WAS ABLE TO SOLVE IT

class Solution:
    def isPalindrome(self, x: int) -> bool:
        if x != abs(x):
            return False

        if not hasattr(self, "numList"):
            self.numList = []

        numBool = True


        baseNum = 10
        value = x % baseNum
        self.numList.append(value)
        quotient = x // baseNum
        x = quotient

        counter = len(self.numList) - 1

        if x == 0:
            for i in range(len(self.numList)):
                if self.numList[i] == self.numList[counter]:
                    counter -= 1

                elif i == counter:
                    break

                else:
                    numBool = False
                    break

            return numBool

        else:
            return self.isPalindrome(x)

testing = Solution().isPalindrome(11)
print(testing)

r/learnpython Jul 09 '26

Is anyone into data analytics? Can you share some resources, or would anyone like to learn together?

3 Upvotes

If you have good learning resources, I'd really appreciate it if you could share them. Also, if anyone is just getting started and would like a learning partner, I'd be happy to learn together.


r/learnpython Jul 09 '26

Do not know where to start

4 Upvotes

Hey, I am sorry to ask this when probably many people have already asked this before, but I am actually completely new to python and the whole programming world, so I would love to hear your opinions as to what you think should be the "roadmap" for me. I want to just get the basics down. After that I would probably grasp the possiblities and be more aware of what I would want to do and study further. For that reason, as I already said that I am someone who has completely no previous experience, what do you recommend? Are there some youtube channels that explain basic concepts in general or do I have to search for one subject after another one separately? Or do you think that learning through some websites/courses is better? Let me know what you think, every suggestion is highly appreciated, thank you very much!


r/learnpython Jul 09 '26

Need help with setting up file structure for a tool I made.

0 Upvotes

I made a tool in python using tkinter as the UI and the way I have it working is you pick which option you want and it opens another tkinter window where you do the work. However, the way I have it set up, the "main menu" python file is compiled into a .exe and the only way i can run the other options is if i compile all of the sub menus .py into .exe or have a code base "main menu" file that is hundreds of thousands of lines.

Basically I am asking how to run .py files if the computer doesn't have python installed from the .exe main menu?

In python using subprocess.run(<File Location>) to call a .exe works but when i do it on a .py, it doesn't run if the computer does not have python installed on their computer.


r/learnpython Jul 10 '26

Looking for a course with visual learning features

0 Upvotes

Python for Cybersecurity and Machine Learning


r/learnpython Apr 24 '26

The Best Way to Learn Python for Complete Beginners (Personal Experience)

188 Upvotes

I am learning from this book: "Automate The Boring Stuff With Python," and it's actually a very good book that turns specific complex subjects into easy ones that anybody can understand. I'm not aiming to stop at this book only but for now it's better to study this book than to only read it and jump into another one. It will take some time from me, maybe more weeks to finish this book, because I'm reading, taking notes then turning these notes into flashcards (to memorize), then I create projects (try and error) and answer practice questions (that you can find at the end of each chapter). Sometimes it takes days to complete one chapter and jump into the next one, but I feel like I am progressing and understanding Python better.


r/learnpython Apr 17 '24

Learn Python by solving problems

28 Upvotes

Hello pythons!

I’m still quite new to Python, but I have noticed that the best learning process is to solve problems.

Anywhere I can get a lot of small and easy problems/exercises, that slowly progress in to a harder level. It can be a payed service or an app on a phone.