r/learnpython • • May 31 '25

Python Crash Course is great and all, but chapter 9 us LAUGHABLY difficult.

61 Upvotes

Did the author forget that he's writing for beginners?

I'm looking at the solution for exercise 9-15 and am just thinking... "What beginner would EVER be able to do this?" The first time I looked at the solution I laughed out loud, because I expected it to be under 20 lines of code with a "trick" to it, but it's literally 70 lines of code with multiple functions, two while loops, setting functions to be called through variables, and setting function attributes using variables. I would have never figured this out on my own.

It's so frustrating, because I swear all these books go from "print("Hello world!")" to "ok now write a program that cures cancer, solves space travel, and brings world peace" within a few chapters.

EDIT: If you're curious about the exercise: https://ehmatthes.github.io/pcc_2e/solutions/chapter_9/#9-15-lottery-analysis


r/learnpython • • Aug 29 '25

when python returns <class 'int'> what does 'class' exacltly mean ?

1 Upvotes

hey everyone ! i'm trying to grasp some python fundemantls and i still find the term "class" confusing in <class 'int'> , 'int' is a class name that follows the same rule as my defined classes in python but 'int' is not defined using python .

i asked chatgbt and it says : 'int' is defined/implemented in C , but how do my classes that are defined in python behave the same way as the built_in ones ?


r/learnpython • • Jun 13 '25

Best way to learn python

0 Upvotes

I want to learn Python over the summer. What do you think is the best way to do it?


r/learnpython • • Jun 16 '26

Is in 2026, what is the best game framework for Python?

1 Upvotes

I'm looking to get back into Python, and have tried PyGame in the past. It was fine, but I'm wondering if there is something newer and better around these days. I'm just making simple 2-D top down or side scrollers, nothing too fancy.


r/learnpython • • May 16 '25

I'm looking for a Python course that's friendly to beginners, can you recommend one to me?

1 Upvotes

I want to learn python, but I am afraid that I can't find a suitable course. I have no other programming language foundation. I want to find a python course that is friendly to zero-coding. Can you recommend it to me?


r/learnpython • • Jul 09 '25

Can't understand why i never grow [frustation]

0 Upvotes

I'm begging, for real. I feel like I was wrong on everything. Python give me this expectation about problem solving.

But to this day, it has none of any practice in really understanding how software are made in low level.

Everytime I'm gonna code in python, there is this terrible lostness until I realized, yeah, everything is modular, make sense.

I have no experience like this in go and fixing error is satisfying.

But why.

Why in the fucking world did setting up installation seems like there is no "pinpoint" as if different device have to speak differently. And why in the fucking world that reading the documentation feel like i'm listening to a developer that is flexing on some concept full of jargon that i have no clue where to first find.

I have no experience like this reading Lua and Love2d. I have no annoyance in reading Linux or C. I also find PHP have weird design choice but i can still understand it.

And why do it need to be a class. I enjoy more reading Haskell than to fucking find what exactly is being read in the interpreter.

Python has introduced me to complex stuff in easier way but as a result my head is empty for really starting on my own and the documentation seems like it's a tribal language.

It's handholding me and I thank it for it. But fuck it, I'm wasting time trying to understand it.

Edit: all the response really did ease me. But perhaps, for all the comparison I made above, reading Lua documentation for example is straightforward, but in python I feel like they gatekeep me with some sort of pre elucidation concept that I should take it further, yet it is bullshit. Please, Get to the point.


r/learnpython • • Aug 14 '25

new to python question was find the greatest of the four numbers entered by user

1 Upvotes
a=int(input("enter your numbera:"))
b=int(input("enter your numberb:"))
c=int(input("enter your numberc:"))
d=int(input("enter your numberd:d"))
if(a>b,a>c,a>d):
    print("a is the biggest")
elif(b>a,b>c,b>d):
    print("b is the largest")
elif(c>b,c>a,c>d):
    print("c is the largest")
elif(d>a,d>b,d>c):
    print("d is the largest")
#this was code

PS C:\Users\docha\Downloads\python> python .\PRACTICE\p14.py

enter your numbera:1

enter your numberb:2

enter your numberc:3

enter your numberd:d4

a is the biggest

this was the result on running code


r/learnpython • • 17d ago

Beginner Python Coder, Which Language For A GUI?

0 Upvotes

Hey all, background is as such:

For a non-Python CS course, I'm supposed to be designing the UI for an offline app. It's supposed to be a notepad app, the kind where you make sticky notes and post them on a board, with multiple people designing different aspects.

The impasse is that, while we've all agreed to do the backend of the app in python, I don't know how to make the front end at all. I'm familiar with HTML, CSS, and Javascript, I thought the process of connecting some backend Python to a front-end of HTML+CSS would be the same as with JavaScript, but apparently it isn't.

Googling around and asking AI, I get recommended libraries and languages like Pyside6, Ttinker, PyQt, Django, and others -- but I've never worked with any of them, and while I've tried to play with Pyside6 and Ttinker for a week now, I could only figure out how to make static notes and shapes, I couldn't figure out dragging and moving like you can with JS listeners. I feel frustration because you can find apps like this all over the place, 5 seconds of googling and you can find one, but I don't know how to make it.

So help me out -- if someone wants to make a GUI, where you have a pretty backboard, put notes on it, click notes, write on them, upload pictures to them, drag them around a board, and you must use Python as the back end, how do you marry the front and back end together?

Edit: Thank you all, I've settled on PySide6 and PyQt. I've just got the hang of making basic buttons, using setGeometry to move their starting locations, having them spawn blank 'note' widgets, and dragging them around. Being able to pin text and images to these widgets will come next, but for now, it works!


r/learnpython • • Jul 14 '25

what are the basic training for Python?

1 Upvotes

what are the basic training for Python?

any youtube links , ebook , visuals or apps , or website

udemy or coursera

the best resources possible


r/learnpython • • Sep 05 '25

Any modern-looking clones of the official Python docs ?

0 Upvotes

I use the python's doc for a very long time now and it's always difficult for me to read with this outdated design.

Is there anyone who (try to?) make a better design for documentation elsewhere ?

I understand that the actual theme is simple and good for accesibility. But I want better-look.


r/learnpython • • Dec 13 '25

From where do I learn python

0 Upvotes

I wnna learn python but im confused with all the yt videos, websites and
docs.
Edit - I also tried chatgpt to coach me but it just throws things my way and doesnt let me actually learn. Should i just continue with chatgpt but give it more precise prompts?


r/learnpython • • Apr 08 '26

How do you avoid getting bored while learning Python?

0 Upvotes

I'm currently learning Python and I really want to become good at it, but sometimes the learning process feels boring.

I've already covered the basics. Right now I'm reading Python Crash Course and working through the Alien Invasion pygame project. I'm mostly following along with the book and trying to understand as much of the code as I can.

Sometimes I get stuck on a piece of code I don't fully understand and I ask ChatGPT for help. When that happens the process can feel slow and boring, even if I take a break or go for a walk.

I'm also building a CLI habit tracker as a personal project that I plan to use long-term and keep improving with new features. That helps sometimes, but not always.

I try to stay focused and avoid distracting myself with things like anime or movies because it makes it harder to get back into learning.

For those of you who became good at Python:

  • What helped you stay interested while learning?

  • Did you focus more on projects, challenges, or something else?

  • Any habits or strategies that made the process less boring?

I'd appreciate any advice.


r/learnpython • • 23d ago

I am not sure why this user defined function is not working.

1 Upvotes

n=1

def continution():

x=input('Do you want to continue?')

if x=='yes':

global n

n=1

else:

global n

n=0

if i input yes there is a big text about an error if i eneter no still something similar

(This is part of a bigger sql python interface project)

This is the error:

Traceback (most recent call last):

File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\mysql\connector\network.py", line 165, in _send_pkt

sock.sendall(pkt)

OSError: [WinError 10038] An operation was attempted on something that is not a socket

The above exception was the direct cause of the following exception:

Traceback (most recent call last):

File "F:\AA main project.py", line 12, in <module>

cur=c.cursor()

File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\mysql\connector\cursor.py", line 416, in execute

self._connection.cmd_query(

File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\mysql\connector\opentelemetry\context_propagation.py", line 97, in wrapper

return method(cnx, *args, **kwargs)

File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\mysql\connector_decorating.py", line 89, in handle_cnx_method

raise err

File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\mysql\connector_decorating.py", line 85, in handle_cnx_method

return cnx_method(cnx, *args, **kwargs)

File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\mysql\connector\connection.py", line 985, in cmd_query

self._send_cmd(

File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\mysql\connector_decorating.py", line 89, in handle_cnx_method

raise err

File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\mysql\connector_decorating.py", line 85, in handle_cnx_method

return cnx_method(cnx, *args, **kwargs)

File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\mysql\connector\connection.py", line 507, in _send_cmd

self._socket.send(

File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\mysql\connector\network.py", line 650, in send

self._netbroker.send(

File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\mysql\connector\network.py", line 223, in send

self._send_pkt(

File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\mysql\connector\network.py", line 169, in _send_pkt

raise OperationalError(

mysql.connector.errors.OperationalError: 2055: Lost connection to MySQL server at 'localhost:3306', system error: Errno 10038: An operation was attempted on something that is not a socket


r/learnpython • • Nov 03 '24

how is 3+5 38? [input function]

0 Upvotes

SOLVED

this is the code:

a=input("value of a: ")
b=input("value of b: ")
print(3+5)
print(a+b)
print(type(a))

its output:

value of a: 3
value of b: 5
8
35
<class 'str'>

I know the default datatype for input function is string, so i thought it would give an error. But the output is somehow 35? Can someone explain whats going on?

another eg:-

input:

a=input("value of a: ")
b=input("value of b: ")
print(4+6)
print(a+b)
print(type(a))

output:

value of a: 4
value of b: 6
10
46
<class 'str'>

r/learnpython • • Jul 17 '19

What is the point of python?

1 Upvotes

I have spent the last couple of days building a python program, and have only been learning python for a couple months or something at this point. I'm really happy with the progress that I've made, this program that I've been making is doing what I want it to and I was ecstatic when I went to bed at 3 am... lol

Today though all that excitement has burnt up trying to figure out how I'm practically going to use this program. The program was built to automate data entry for my job, I deliver pizza for my full time job right now. I'm never in front of a or my computer when I'm delivering pizzas. I was really hoping I could run the program on my android phone.

I tried to use chaquopy with android studio, but I have no experience with android studio so I couldn't figure out how to use it or how to install chaquopy to a AS project. Also python is my first programming language and I'm not ready to learn java just for the sake of making android apps. I also tried to use BeeWare but I think I'm to new to python to be able to use these tools. I also tried to use QPython, which would run the program just fine and I could do all the inputs required to go through my program. This program I'm making requires the writing and appending of files, and QPython wouldn't create or edit the file like it does from IDLE shell.

I'm really frustrated by this limitation, because everything I did was basically for nothing at this point. I've also thought about running teamviewer on my pc and then using the teamviewer android app, but in the past trying to control a pc from an android device in such a manner was very unwieldy and I don't think it would be worth the hassle.

Why is python so self contained and how does one get its usefulness in a more practical manner?

the program in question: https://github.com/itwasntzak/deliveryTracking

Edit: I've also somewhat looked into trying to run the program as a web app through googles app engine environment. Again, I feel I'm to inexperienced in this new vast world of programming to use this implementation. It's also not the most desired implementation, because I live in a very rural part of america. Verizon has a very strong monopoly where I live, I tried to get a cheap phone off amazon and this phone turned out to be GSM instead of CDMA. I got my service though straight talk and they have support for GSM, but only conditionally thought CDMA towers. I constantly lose service thought out the day, and have to restart my phone to get it to even connect to data. When it is connected, the vast majority of the time it is incredibly slow and takes for ever to load even the most basic webpages. This wouldn't be the best way to go for me either because I might spend more time waiting for the program to load and the automation benefits would probably be lost to the waiting times. \

Idk, I'm frustrated lol please give me some advice on what my best course of action will probably be!


r/learnpython • • Oct 13 '24

My if statement doesnt work

1 Upvotes

Can anyone find any errors here? Im new to python so I dont know what I did wrong as every answer is responded with “it has 30 days”

month = input("Enter a month: ") month = month.upper() print(month) if month == "SEPTEMBER"or"APRIL"or"JUNE"or"NOVEMBER": print("it has 30 days") elif month == "JANUARY"or"MARCH"or"MAY"or"JULY"or"DECEMBER"or"AUGUST": print("it has 31 days") elif month == "FEBRUARY": print("it has 28 days, but 29 on a leap year") else: print("That's not a month")

This is what the output is like Enter a month: a A It has 30 days


r/learnpython • • May 25 '23

36 years old. Started an operator certification (1 years and a half) but looking to go into coding. Am I too old ?

1 Upvotes

Thanks for advice


r/learnpython • • Jul 24 '24

My thoughts about Python

1 Upvotes

I started to learn Python a week ago.

It's a brief version of our real language, and makes our communication with computer more efficient.


r/learnpython • • Jul 01 '24

can i delete __init__.py in each package ?

0 Upvotes

why i need it , i dont see any benefit about using it


r/learnpython • • Jan 12 '26

For loop not removing every item in the list.

1 Upvotes

Hi all,

I have just started learning python and I have been having really fun. I am currently looking at the 'for' loop and there is a confusion that has set in for me and I can't figure out the logic behind why it's not working. Hope you all can help me understand this:

number = ["one", "two", "three", "four", "five", "six", "one", "one"]
for num in number:
        if num == "one":
                number.remove("one")
print(number)

The following gives me this output:

['two', 'three', 'four', 'five', 'six', 'one']

Why are all the duplicated value "one" not deleted from the list? I have played around placing several duplicate "one' on the list and have noticed infrequencies. It deletes some of the duplicated value and some it doesn't delete at all.

Also I have noticed that if I use the following, it seems to delete everything:

for num in number[:]

Can someone please explain to me what is going on here as I am really lost?

Thank you


r/learnpython • • Mar 17 '26

I want to make a game in Python.

0 Upvotes

Hi,

What do I need to know and what should I use to make a game in Python? I previously used pygame. But I want something different.

Initially I thought about doing it in C or C#, but I really need to learn Python.

Can someone help me?

Thx.


r/learnpython • • May 05 '25

Learn python or not ?

1 Upvotes

Hi.I am medical student. I have busy hours and python i need to learn to reduce my work load but just as a hobby though. Will it really help me or waste my time?


r/learnpython • • 16d ago

Python interview questions

0 Upvotes

Hi team, please share your interview experience and questions for python developer role


r/learnpython • • Jun 25 '25

Im great at coding logic but intimidated by libraries, the command line, and GitHub. Do I have a shot at this?

0 Upvotes

I start school in September but am trying to learn through online resources. Having trouble! I keep having issues with the command line :/