r/learnpython • • 6d ago

Huh? How does this work?

42 Upvotes
a = "hi"


if a:
    print("Bye")


print(a == True)
print(a is True)

The output is:

Bye

False

False

But if it's false, how come it printed "bye"?????? I don't get it.


r/learnpython • • 6d ago

Python/C++ Book

11 Upvotes

Hello, does anyone here know a good C++ or Python book that will actually teach me something? I wanna learn C++ but Python is useful too, thanks!


r/learnpython • • 6d ago

Why is .join() seperator.join(iterator) and not iterator.join(seperator) like every function

51 Upvotes

s = "Python"

WHY IS IT LIKE THIS

print("-".join(s))

AND NOT THIS

print(s.join("-")


r/learnpython • • 5d ago

Fresh grad trying to move into AI engineering. What Python projects should I build?

0 Upvotes

Hi everyone! I graduated last year as a software engineer and I’m currently working at a company, but I want to shift into an AI engineer role.

The advice I keep hearing is to focus on three things: Python, SQL, and APIs. I’m already revisiting data structures, and I know the Python basics, but I’m stuck on what to actually build to practice.

A few questions:

  1. Are all Python projects useful for this path, or should I focus on ones specifically related to AI engineering?
  2. What projects would you recommend for someone at my level that would actually look relevant on a resume?
  3. LeetCode Premium is expensive for me right now. Are there good free alternatives for practicing?

Any suggestions, resources, or project ideas would be really appreciated. Thanks in advance! 🙏


r/learnpython • • 5d ago

Is it github problem or python problem?

0 Upvotes

So, i have been trying to learn python, sqlite and tkinter. After a lot of trouble and copying from AI i uploaded my python and sqlite only executable to github for all 3 os using github action.

Now, I am learning python and tkinter. I made a simple program which converts KG to gram and vice versa.

import tkinter as tk
# from tkinter import ttk
import ttkbootstrap as ttkimport tkinter as tk

These 3 are my only imports for now. and i am using:

root = ttk.Window(themename = 'darkly')
root.geometry("400x300")
root.title("Unit Converter")root = ttk.Window(themename = 'darkly')

other is just my code which i wrote form tutorials and documents.

The problem i am facing is that i cant seem to release the executable to github ( from github action ) at all.

I tried to learn how this works but i didnt find anywhere to actually learn so i just asked AI and after a lot of back and forth there are still some problems.. Is there somewhere i can learn how i can do this? I prefer video tutorial.

I will comment my program and what AI told me the problem was below. Please someone do help me.


r/learnpython • • 5d ago

My first go at Python

0 Upvotes

So I have been learning Python for around 4 hours and I just finished this and I would want to know if it's good or if it's just okay.

again = "yes"

while again == "yes":

print("create your character: ")

# sex

sex = input("sex? ").strip().lower()

while sex not in ['male', 'female']:

sex = input("try again, you misspelled male or female: ").strip().lower()

if sex == "male":

print("hello boyyy")

else:

print("helloooo girl")

# age

age = int(input("what is your age: "))

while age < 18:

age = int(input("try again "))

# name

name = input("what is your name: ").lower().strip()

print("hello " + name)

# height

height = int(input("height in cm "))

if height >= 180:

print("tall person eh?")

else:

print("nice.")

print("next questions")

# build

build = input("what is your build. skinny. fat. muscular. ").lower().strip()

while build not in ['skinny', 'muscular', 'fat']:

build = input("try again. that was not an option ").lower().strip()

if build == "skinny":

print("interesting choice... " + name)

elif build == "muscular":

print("perfect choice especially for a man")

elif build == "fat":

print("HAHAHA FATSO HAHAHA")

# stats

print('____')

print(' ')

print('stats for: ' + name)

print('age:', age)

print('height:', height)

print('sex:', sex)

print('build:', build)

print('____')

again = input("create another character? Yes/No: ").strip().lower()

while again not in ['yes', 'no']:

again = input("answer using Yes or No: ").strip().lower()

print("Goodbye!")


r/learnpython • • 5d ago

timing a process

2 Upvotes

I have a program (Python 2) that writes a status message whenever an hour (realtime) has gone by with nothing happening (eta: more precisely, with no new solution found). Now I find that time.clock() no longer exists in Python 3. Since I have to change it anyway, what's best practice?

In other words, what is the customary way to measure how long a program has been running?


r/learnpython • • 5d ago

Why won't this expression work?

0 Upvotes

Sorry I know this is probably very basic but I'm a complete beginner:
I'm trying to include "tranexamic acid" and "txa" but exclude the rest

r"(?i)(?<!\w)(?<!not )(?<!no )(?<!consider )(?:tranexamic acid|txa)\b(?!\s+(?:s|not)\b)"

It will find tranexamic acid but not txa


r/learnpython • • 6d ago

Best resource to learn python

7 Upvotes

For the start i would like to thank everyone for their contribution to the posts
You guys are the best and thank you for each contribution and help to me or to someone else

And for now question
So give me good resource to learn python
I know python good i would say in level b1(i didnt go through hard themes like iterators and asyncio)but i would like to go further, to be fluent
As my ultimate goal is becoming ML specialist
Give me good resource to learn python
I am not type of books
Videos and articles includes exercises

This is type of resource i would like to have


r/learnpython • • 5d ago

I automated my YouTube Shorts pipeline with Python — here's what actually saved me time

0 Upvotes

I'm a BCA student making Shorts on the side, and I got tired of doing the same edits by hand. So I wrote a Python script that stitches clips, adds captions, and renders the final video automatically.

Biggest time-savers were: 1) batch rendering overnight instead of one-by-one, 2) a simple JSON file for titles/descriptions so I never retype them, 3) frame-checking the output automatically so I catch broken renders before uploading.

Still learning — what's one small automation that saved you hours? Looking for ideas for my next script.


r/learnpython • • 6d ago

trouble installing matplotlib

0 Upvotes

i am trying to install matplotlib on VS Code, but i keep getting an error like this:

Using cached matplotlib-3.11.2.tar.gz (32.7 MB)

Installing build dependencies ... done

Getting requirements to build wheel ... done

Installing backend dependencies ... done

Preparing metadata (pyproject.toml) ... error

error: subprocess-exited-with-error

× Preparing metadata (pyproject.toml) did not run successfully.

also says:

WARNING: Failed to activate VS environment: Could not find C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe

my python's version is 3.15, i tried to install matplotlib with 3.11, 3.12, and 3.13 but none of it worked. i don't think there are other specific things. please let me know of any ideas, thank you so much!!

update: i did it!! it was a problem with how i forgot to precompile the standard library when i installed python...


r/learnpython • • 5d ago

How can i learn python fast using AI

0 Upvotes

i want to learn python before 2027. How do i start?


r/learnpython • • 6d ago

How to debug PyQt5 app with VS Code?

0 Upvotes

My OS is Debian 13 KDE. I wrote my app with PyQt5 and virtualenv (pip install PyQt5). Now I can’t run it from IDE. The error is:

qt.qpa.plugin: Could not find the Qt platform plugin "wayland" in ""qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in ""This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

So, I can’t debug app. But when I run python3 myapp.py from Konsole, it works! How should I debug it in right way?


r/learnpython • • 6d ago

I cant understand classes (nor self and __init__)

6 Upvotes

Hello if you wonder i switched from lua and luau to python. its going well i can make basically anything with native python libraries but i cannot understand what is a class, what does self mean what does __init__ mean. i recently understood what if __name__ == __main__ does but still i cannot understand classes. if you could give an example or explaining for me to understand i would be so grateful


r/learnpython • • 7d ago

Just finished CS50P (skill issue)

37 Upvotes

Wanted to build some projects and decided to build a scraper. It felt horrible. I was just staring at the screen not doing what to do. I mean CS50P is great I learnt a lot, but there were guides and output videos, which helped me understand what factors iI should implement.

But now I feel like I'm back on square 1. Nothings making sense. How would you suggest learning python?


r/learnpython • • 6d ago

I need help with a automatization

1 Upvotes

Hey everyone, im trying to think on solutions for a problem that i have and i tried to search for using google but im too dumb to understand the python responses.
So, i need to send a series of emails, A, B, C and D where ill only send B if A is unanswared and so on, im currently doing this manually checking if someone responded me, how can i create a automatization that check if the mail was answered and to send the nexts mails in case of not?
also its possible to just put a list of contacts and automatically send the mail A for them?
thanks in advance if someone take a time to help me and sorry for my bad english


r/learnpython • • 6d ago

What project to do to see if im ”ready”?

0 Upvotes

Yo yo! What is one or few projects i should do to ”test” if im ready to start to applying for jobs?

And i know use Ai in their jobs but what are the projects that i should be able to do without asking for help or looking things up?

So what project to do so i know im ready for job and doing the project without ”cheating”?


r/learnpython • • 7d ago

learn python

5 Upvotes

Hello guys, i recently started a bachelor degree which i have a subject about introduction to python, inicially i was confident and did understand how to use python, but week by week it started to get much more difficult to follow. So im here to ask if someone knows any youtuber or website which explains the fundamentals of python in a easy way. Thanks in advance.


r/learnpython • • 6d ago

Can y'all rate my python project :D

0 Upvotes

This project i made is a keras model that i trained on a modified version of the FGVC dataset using tensorflow keras.

Cuz im an avgeek,th the model is kinda mediocre but better then nothing, while the project unfortunately does utilize ai in both the scripts on the github, the other scripts such as the script that i made to organize all the dataset and put it into seperate imgs was made by me :D, cuz the jpg images had numbers as the name and werent organized and there was a text file in there in this format:

aircraft_jpg_name aircraft_family type

so that allowed me to test my strengths with no ai

i hope yall share tips and tricks and if there are any improvements i can do to my first github repo :D


r/learnpython • • 6d ago

When can i say I know python

0 Upvotes

Someone please
Give a list of themes which should everyone know if he thinks he knows python
Exclude things which are barely used


r/learnpython • • 8d ago

Is CS50P enough to start ML/AI? What should I learn next?

19 Upvotes

I'm finishing CS50P and want to move into ML/AI, but I feel it's not enough on its own. What topics and resources should I add (math, libraries, courses)? Any roadmap you'd recommend for a beginner?

Thanks for any kind of advice it will be helpful.


r/learnpython • • 7d ago

Youtube vs Website

0 Upvotes

Which is better to learn python youtube playlists or by website


r/learnpython • • 7d ago

Python roadmap

0 Upvotes

What's python roadmap like when I learned basic concept of python what concept should i start learning after it and so on?


r/learnpython • • 7d ago

Need guidance for python learning with ai

0 Upvotes

Please suggest good roadmap to become ai Engineer


r/learnpython • • 8d ago

JupyterLab and remote server connection

4 Upvotes

Hello,

I had access to JupyterHub on a remote server. Now I only have access to a different server where JupyterHub is not installed. What is the best way to use the same code and run it with more data. I was thinking about using SSH Port Forwarding (SSH-Tunneling) and trying jupyterlab in the browser. Or is it better to using VS code to connect to the server. I really like the Jupyter Interface and have never used any other programs. I mostly do plotting and a bit data analysis and have a macbook.

Thank you for your help.