r/learnpython

WAR Card Game Weird Glitch/Bug

So I was making a WAR Card Game in python. Simple. Neat.

But, I encountered a weird glitch. The game kept getting into an infinite loop. I tried to ask Claude but even Claude couldn't understand it.

So I put Claude on Max mode and it gave some answer but still the answer it gave was like tooo hard to understand. It said something about the cards not being random while the game is going on etc.

Can someone pls explain me the bug? https://github.com/KushChandak/WAR/blob/main/WAR%20(3).ipynb here is the code

reddit.com
u/YogurtDisastrous8003 — 2 hours ago

python project ideas pls

hello, i'm a beginner at coding python and is there any python project ideas you guys would recommend for people like me? I know how to use APIS, can make a simple digital clock in tkinter using the time module and that's all i think i can mostly do, thank you!

reddit.com
u/i-like-my-cats-0 — 4 hours ago

Is doing DSA in Python actually bad for placements?

I'm currently in my 3rd year of BTech CSE and I've been learning DSA in Python.

Lately a lot of people around me have been telling me that I'm making a mistake and that doing DSA in Python will hurt my placements. They keep saying things like Python has too many built-in functions, C++ is the proper language for DSA, recruiters prefer C++, etc.

Now I'm a bit confused because I've already spent a decent amount of time learning and practicing DSA in Python. My goal is mainly internships and software engineering placements, not competitive programming.

For people who have gone through placements/interviews:

  • Did you use Python for DSA and coding rounds?
  • Were there companies that didn't allow Python?
  • Do interviewers actually care about the language or just whether you can solve the problem?
  • Is it worth switching to C++ at this point?

Would appreciate hearing real experiences rather than just college rumors 😅

reddit.com
u/Character_Cold4105 — 3 hours ago
▲ 34 r/learnpython+1 crossposts

Any beginner Python learners here?

Hello,
I'm a 17 years old beginner in python programming. I have along term goal to study in computer science in university, but other than that , I'm genuinely interested in learning programming languages and create something meaningful like websites and other useful application. I have just started learning the basics of python, for instance, the variable, if-else condition, input function , casting, and simple loop.

I am still at the beginning of my journey , so i would appreciate some helpful advice from other programmers on how to improve efficiently

I'm also looking for other beginners (or even intermediate programmers) who'd like to learn together, share progress, motivate each other, or just have someone to talk to about coding. Learning alone can sometimes feel overwhelming, so having a few coding friends would make the journey much more enjoyable.

If anyone interested, feel free to leave a comment and send me a message. I'd love to get to know people who are on the same journey and grow alongside!

P.S: I would appreciate if you would overlook my broken English. Thank you.

reddit.com
u/False-Seaweed-3349 — 1 day ago

Hi i am from india and i want to learn python before i join my college(atleast have basic idea)

So im joining college this year and I wanted to learn python. After going to college also i am planning to take a udemy course of python and study from it. Till now I learnt some python from vamsi bhavani(telugu people might know him). I studied till loops but did not practice it in my laptop. Anyone who has learnt python can you tell me tips and mistakes to avoid while learning it.

Any advice would be appreciated

reddit.com
u/FewFly2677 — 1 day ago

En uzun kelimeyi bul

Cümledeki en uzun kelimeyi ve kelimenin uzunlugunu soyle.

Bu soruyu neden çözemiyoruz:

HATA:

for w in sentence:

print(w) derseniz.Bunu karakter listesi gibi algılar.

HATA2:

state olusturup update yapmamak yada kosulu yanlıs dizayn etmek

işte çözüm:

def longest_word_sentence(sentence):
    
    words = sentence.split()
    prev=""
    for w in words:
       if(len(w) > len(prev)):
         prev = w
       else:
         continue
    return [prev,len(prev)]
if __name__ == "__main__":
    sentence = input("Enter a sentence: ")
    result = longest_word_sentence(sentence)
    print(f"The longest word is '{result[0]}' with length {result[1]}.")
reddit.com
u/Traditional-Quit9043 — 23 hours ago

Should I learn Python for trading?

The thing is, I have no prior programming experience, so this seems like a big step. I'm wondering how much I need to learn to use Python.

For those of you who are traders and know Python, has learning it made a significant difference? Or is it only worth learning if you want to build your own tools or automate everything?

I want to start from scratch, so do I still need to spend time learning Python?

reddit.com
u/Worldly_Growth_50 — 1 day ago

What’s the biggest time-wasting problem in your work that AI still hasn’t solved?

Hi everyone,

I’m currently learning Python and working toward building AI products that solve real problems.

Before I start building, I want to understand what people actually struggle with instead of guessing.

If you could automate one repetitive task with AI today, what would it be?
・What do you do new instead?
・How much time does it cost you every week?
・Have you tried any existing tools? Why weren’t they good enough?
・Would you pay for a solution?

I’m not looking for random startup ideas. I’m trying to understand real problems from real people so I can build something genuinely useful.

Thank you in advance for sharing your experiences!

reddit.com
u/Gcat1127 — 1 day ago

vscode and ruff

Hi,

I use vscode to write my Python scripts.

I want my code to be formatted automatically, black-style, and I want my imports to be automatically ordered. However, I do NOT want unused imports to be removed. I find this behaviour to be a major pain in the ass when writing code and saving every once in a while.

I am trying this json config but while it's not removing unused imports anymore, it seems to have stopped re-ordering imports altogether:

"ruff.configuration": {
    "lint": {
        "unfixable": ["F401"],
    },
},

What is the right way to approach this, please?

Thank you.

reddit.com
u/paranoid-alkaloid — 22 hours ago

Thinking of forcing myself to guess how to fix my Python code before asking AI, anyone actually done this long-term?

Saw a bunch of good advice in a thread here recently about not letting AI think for you: the "explain the fix out loud before you commit it" rule, the "could I rewrite this in 2 weeks" test, stuff like that.

Been thinking about turning it into an actual forced habit instead of just something I agree with in the moment: before I'm allowed to ask AI anything, write down my own guess first. Only after that, compare it against what the AI says.

My hesitation is that this is exactly the kind of rule that sounds great for about two days and then quietly disappears the first time I'm in a rush. "Study the AI's output carefully" is advice I've seen (and honestly given) a lot, but studying something after the fact still isn't the same as actually generating it yourself first. I just don't know if the forcing-function part is realistic to sustain without something external holding you to it.

Has anyone actually tried something like this as a real enforced habit, not just a good idea you nodded at? Did it stick? Did you need some kind of external structure to actually hold yourself to it, or did it fall apart after a few days like most self-imposed rules do?

reddit.com
u/Ok-Barnacle-2508 — 2 days ago

python beginner ; question was write program to enter marks of 3 subjects from user and store them in a dict.start with an empty dict and add one by one .use subject name as key and marks as value . so i have written this code any opinion how can improve this code ,need suggestions.

students={}
a=float(input("enter marks of chem"))
students.update({"chem": a})
b=float(input("enter marks of maths"))
students.update({"maths":b})
c=float(input("enter marks of phy"))
students.update({"phy": c})
print(students)
reddit.com
u/Ill-Break727 — 2 days ago

Searching for a Python 'complier' if it exist

Hello,

I'm searching for a compiler for my Python game so It can run faster and can be package in a standalone file (without need of Python installed on the host)

reddit.com
u/Weydoon — 1 day ago

Can somebody give me numpy project idea?

I have a task at my university, in which i should show my knowledge of numpy library and create a project that uses numpy functions. And i can't think of any idea...

Pls give me ideas of projects where i can use matrix for example or any other numpy logic🙏🙏

reddit.com
u/South-Property2771 — 2 days ago

Python for finance

Im a bcom fresher who wants to enter the finance sector with as much skills as i can possibly hoard. I want to make sure that the skills that i learn are relevant to the work i will do in the future.

I dont have much experience with python either. I only know the basics and i want to transition my learning towards finance side of python. How do i do that?

What libraries do i need to learn?
What concepts should i focus more on?
Is there a resource to learn python for free and efficiently?

reddit.com
u/Hully_Delta — 1 day ago

Where does it make more sense to learn Python?

I have a non-tech background and work in the insurance industry. I want to learn Python to automate daily operations and manage data. There are endless options like Udemy, YouTube, or AI's . Where is the most practical place to start? Should I follow a structured course or just jump into building projects? I want the most efficient learning path. What worked best for you?

reddit.com
u/Luellias — 2 days ago
▲ 9 r/learnpython+3 crossposts

I built an AI agent that fills job applications for me — it got me interviews at Cohere and Scale AI. I review and submit every one myself.

Job searching was eating hours a day, mostly on copy-pasting the same info

  into slightly different forms. Recruiters used to find me on LinkedIn, but

  that dried up — so I bit the bullet and built an agent that:

  - finds open roles across job boards

  - rewrites my resume for each job and generates a fresh PDF

  - fills out the actual application (Ashby, Greenhouse — dropdowns, comboboxes,

  the "why do you want to work here" boxes)

  - **stops before submitting** so I review every application — it's an

  assistant, not a spam cannon

  Result: interviews at Cohere, Scale AI, and others I'm confident would never

  have called me back otherwise.

  Built with Python + Playwright + an LLM doing the form-field mapping. The

  hardest part by far was handling how differently every ATS renders its forms.

  Code: https://github.com/torontodeveloper/job-application-agent

  Full demo of it applying to real jobs:

  https://www.youtube.com/watch?v=SM7EIgbBiiY

  AMA about the build — curious whether people here would trust it to submit

  autonomously (I don't, yet).

u/torontodeveloper1 — 2 days ago

How to avoid this when learning Python?

When learning I used to get stuck on stuff, go watch a video or dig through docs, and eventually the concept would click because I had to sit with it.

Now when I get stuck I just paste the error into Claude/ChatGPT and it fixes it in 10 seconds. Problem solved, moving on with my day. Except a week later I hit basically the same bug and I'm back to square one, like the first fix never actually taught me anything.

It feels like it's the same "watching tutorials without building anything" trap, just compressed into single lines of code instead of hour-long videos.

Curious if anyone here has found a way to use AI for debugging without it just doing the thinking for you? Or do you have some rule for yourself about when you're allowed to ask vs. when you have to sit with it first?

reddit.com
u/Ok-Barnacle-2508 — 2 days ago

How to create a compiler?

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.

reddit.com
u/UnemployedTechie2021 — 2 days ago

Python conversion .docx to pdf

Hey guys, i have been learning python as a bit of a hobby but recently had the opportunity to use it for my job. I built a webapp on azure that has a number of different functions, one of which is querying our CRM and populating template documents with customer info. It works as is and produces .docx files which we then have to manually convert to pdfs.

I am trying to incorporate the pdf conversion into the app to remove any manual intervention. Ive been using libreoffice but this isnt working so well. It needs to be installed each time the app is redeployed/restarted, its failing on some larger docs and when it does produce the pdf the format can be off, fonts change etc. The docs we deal with need to adhere to a specific format so I need something more reliable.

Perhaps this is a "you get what you pay for" situation but i was hoping there might be a more reliable solution while still being free (at least until i can prove it all works anyway).

reddit.com
u/billys-bobs — 2 days ago