r/learnpython • • Jul 20 '24

In light of recent events…

1 Upvotes

I am not a professional python dev, but always learning. Busy on my own flask-based project at the moment. Thoroughly enjoying it.

By the CrowdStrike error, and utter vulnerability has made me ponder how much power a language like Python has.

Don’t get me wrong, I’m totally aware that Python is used extensively in cybersecurity, but I’ve never heard of Python being able to cause a BSOD / Kernel Panic. Am I wrong here?

My understanding from ready the current speculation is that CrowdStrike offers a anti-malware solution, primarily to large corporates and governments. The issue was with a content update which seemed (and here’s where the speculation starts) to be a corrupt signature / content file, and when the system tried to load the content, it wasn’t there. There was an attempt to access a dereferenced null pointer (per some) or load a page of content that wasn’t in the update file (per others).

One comment I read is that as an antimalware program, it plays around in Kernel space, rather than in user space.

Are there examples of Python playing in Kernel space? Is this possible? Is it even possible to force a BSOD or Kernel Panic in Python?


r/learnpython • • Jul 26 '24

Best way to learn python for free ?

0 Upvotes

Hello everyone im studying cs and would like to learn mlre about python


r/learnpython • • Dec 29 '23

Getting bored.

1 Upvotes

I have been reading python crash course. I worked my way up to dictionaries and am finding myself losing interest mostly because of the boring things that are used as examples. I just don't find it fun.

And there's Alot of pages to cover. Would it be ok to just at least read the rest of the book then start working on my own projects?

I don't want to jump into making something and the language kind of be foreign to me. For example the def init I seen and was like wtf is that lol.

How would you guys recommend I go about this? I don't want to quit just want to kind of venture out of the book soon.


r/learnpython • • Mar 31 '24

Am I wasting time learning python or programming if I only plan to use it on the side?

0 Upvotes

I already have my main labor job that pays pretty good for almost 12 years now and is very stable, but I want to dedicate my hours after work to something that I could use in the future in the event that I get laid off. I'm not hurting for money in case anyone was suggesting that I just work part time elsewhere or at a store and would rather use that time and energy towards a useful skill.

I have taken a few C and Java courses in my younger years, but I have no intentions of returning back to college just to get a degree so I will just teach myself how to program primarily because some of the classes required for a degree doesnt work with my morning job schedule. So far after a week in, I'm able to do very basic things such as printing using fstrings with variables, getting users input, defining several functions and making simple calculations with users inputs using if, and, or, elif statements. Right now I'm learning about booleans and how they work using def.

The process is slow as I only have a few hours after work before I need to do other things then hit the bed right after. But my overall goal is to just have a relatable skill I can potentially use in the future in the tech field and just make programs on my down time and expand my skills overtime. I'm also getting started in IT basics as well. What I like about both of them is that I can pretty much study and work on them whenever I want. Maybe I would want to switch over when I get older, but then again who would want to hire a non grad in their 40s or 50s?


r/learnpython • • Apr 05 '24

type("hello" == "world") returns BOOL - How?

0 Upvotes

HELLO WORLD! I am a newbie to Python.
Came across this line of code which results in "Bool". Can you please tell me how this expression returns a boolean type -
type("hello" == "world")


r/learnpython • • May 17 '24

Where to learn USEFUL python?

0 Upvotes

Hello!

I'm talking about python that will actually help me write scripts I want.

Earlier around 2019, I did an in-person python class with someone popular in my city and he literally taught me nothing but simple syntax and functions, which I already knew before attending. This wasn't supposed to be a basic class, mind you. This just shows the level of python knowledge my country has.

Anyways, I want to program a plan organizer/alarm app for starters.

I only know python basic functions and syntax.

Help me. Where to go from here?


r/learnpython • • Sep 10 '24

Looking for a beginner progrsmmer in python

1 Upvotes

I am an intermediate pythonista and right now I want not to specialize but to try help anyone (a beginner) where i can. I just want to soldify my basic knowledges of the language before i start to specialize. So if there is snyone interested dm me


r/learnpython • • Sep 26 '24

Empty strings - am i tripping?

1 Upvotes
>>> '' in 'abc'
True

can someone explain? (python 3.12.6)


r/learnpython • • Sep 05 '20

ASSALAMU'ALAIKUM, CAN YOU HELP ME!

0 Upvotes

assalamu'alaikum, I am a beginner in this matter I want to ask why when I change my python file to exe it works, but when opened it says like this:

Traceback (most recent call last):

File "C:\Users\HP\anaconda3\lib\runpy.py", line 183, in _run_module_as_main

mod_name, mod_spec, code = _get_module_details(mod_name, _Error)

File "C:\Users\HP\anaconda3\lib\runpy.py", line 109, in _get_module_details

__import__(pkg_name)

File "C:\Users\HP\corona\Destroythecovid19.py", line 408, in <module>

background = pygame.image.load(path.join(img_dir, "background/corona2.")).convert()

pygame.error: Couldn't open C:\Users\HP\corona\image\background/corona2.


r/learnpython • • Jul 21 '13

Not sure if this has been asked before, if so I apologize.

0 Upvotes

I'm doing the 100 programs & I've come upon something I just don't get. Could someone explain the Fibonacci sequence in python. I would really appreciate any help understanding how it's generated in python.


r/learnpython • • Jul 22 '22

Stuck on an error that says I haven't defined something when I have for my "choose your own adventure" text adventure game NSFW

1 Upvotes

So the story is erotic so heads up for that. But basically I am trying to define a path and I already have defined it and I think I have done everything right but even though I did the def thing, it still doesnt recognize my command and says that "path3 isnt defined". Any ideas on what could cause this error?

print()
print()
print(" (============3")
print("     CORNUTO")
print(" (============3")
print()
print()
name=input('Whats your name cuck? ')
print(f'Hello' , name, end=' ')
print('Welcome to Cornuto, a Fantasy Text Adventure!')
print()
print()
print("A function is happening at your castle.")
firstPath =input("three paths reveal themselves to you, do you go down path 1 \n and attack a neighboring mayor, path 2 and head to the taven or \n do your duty and go to the castle?, by heading down path 3")
print()
if firstPath == '1':
    print()
    path1()
    
elif firstPath == '2':
    print()
    path2()
    
elif firstPath =='3':
    print()
    path3()
else:
    print("invalid response, you lose")
    
def path1():
    print()

def path1_1():
    print()

def path1_2():
    print()

def path1_3():
    print()

def path2():
    print()

def path2_1():
    print()

def path2_2():
    print()

def path2_3():
    print()

def path3():
    print("You decide to attend the party at your small castle.")
    print("Leo, your finest knight with raven hair and piercing eyes is chatting with your wife. \n She giggles at his wit and jests.")
    print("Felipe, the jester begins singing a song about a cuckolded count")
    print("Leo's hand briefly touches your wifes hand. \n You feel a strange sensation in your chest")
    print("Mordechai Aquilo, your court physician begins remarking on the tradition of cisibeo, a courtly non monogamy \n found in the other provinces.")
    print("Leo and your wife share a glance. At this point \n you are filled with jealousy as everybody seems to be whispering to one another")
    print("Curiously, your body hair is gone, you realize as you look down your shirt, and your nipples are swelling and achey")
    



def path3_1():
    print()


def path3_2():
    print()

def path3_3():
    print()

r/learnpython • • Aug 21 '25

Someone told me to go here so...

0 Upvotes

I'm a teen who want to learn programming and someone told me to go here to learn so I'm here. I don't know a thing in programmation so pls can u help me ?

Thanks


r/learnpython • • Sep 15 '24

What's the difference between % (modulo) and // (floor division)

1 Upvotes

Hello, Can someone please explain the me the difference between those two arithmetic signs because am new to programming python:)


r/learnpython • • Aug 01 '26

Understanding the "or" function

0 Upvotes

i have a pretty simple few lines of code, and i'm slowly trying to make it a bit more complex

All i want to know is why adding the "or" function onto my if functions makes the functions further down "unreachable"

*I have hashed them out in the example i have provided as this makes the code run fine*

thankyou

while True: 


        if user_input1.lower() == "y": #or "Yes" or " yes" or "Y" or "YES":
                total_monthly_yield_exclnvda = float (total_monthly_yield - nvda_div_yield_at_190726 )
                avg_yield_on_remaining_shares_adj = float ( total_monthly_yield_exclnvda / 3)
                print (f"With Nvidia's dividend yield at {nvda_div_yield_at_190726} the three remaining shares need a current dividend yield of {avg_yield_on_remaining_shares_adj}, or over")   
                break


        elif user_input1.lower () == "n": #or "N" or "No" or "no" or "NO":
                current_div_yield = float(input ("Enter Nvidia's current dividend yield: "))
                total_monthly_yield_exclnvda = float (total_monthly_yield - current_div_yield)
                avg_yield_on_remaining_shares_adj = float ( total_monthly_yield_exclnvda / 3)
                print (avg_yield_on_remaining_shares)
                print (f"With Nvidia's dividend yield at {current_div_yield} the three remaining shares need a current dividend yield of {avg_yield_on_remaining_shares_adj}, or over")   
                break 

r/learnpython • • Mar 11 '26

How can I automate with python

1 Upvotes

Hi! I am in a bit of a dilemma, I want to start earning at least a little so as to contribute financially to my family. I want to look into automation using python so I can freelance in this field. I already know python concepts but the problem is, any automation tutorial I watch doesn't feel like I can replicate it and so I don't understand it. I am not able to use what I know in python and link it to automation and I don't know where to start. What do you suggest, how do I carry through with this?


r/learnpython • • Oct 14 '25

How do multiple layers of nested if-then statements work?

0 Upvotes

I have an assignment for a class I'm in to make a choose your own adventure type of game, and I've hit a wall. I've got multiple layers of while True statements, and I think I'm missing some breaks but I'm not sure. Any tips for a noob?

while True:
    c1 = input("As you enter the cave, you see green light bathing the cold stone walls. As you turn the corner, a sizzling bolt of emerald energy flashes towards you. You duck, and it collides with the bare wall behind you, leaving a sizzling black scorch mark. You raise your eyes and see a lich, cackling as he raises his staff. The staff begins to glow, preparing another attack. What do you do? CHARGE the lich. Call upon MAGIC. TALK and attempt peace. FLEE from the cave. ")
    c1 = c1.lower()
    print("")


    if c1 == "charge":
        while True:
            c2 = input("You charge forward, sword drawn, shield at your side. The lich begins to slowly levitate upwards, throwing bolt after bolt in your direction. One whizzes harmlessly over youur shoulder, and you deflect another with your enchanted shield. The lich roars in a forgotten language as you get closer. You leap off the ground, soaring towards the vile undead. What do you do? SLASH at his head. STAB at his heart. BASH with your shield. ")
            c2 = c2.lower
            print("")


            if c2 == "slash":
                while True:
                    c3 = input("You swing your blade, aiming for the neck of the vile lich. The sword connects with century-old bone, and green sparks fly out from the severed stump. You land on your feet, and the lich explodes into ash above you, littering black powder all around the floor of the cave. His crumpled empty robes land in a heap in front of you, but his staff never hits the ground. Instead, it levitates on its own, a few feet off the ground. What do you do? TAKE the staff. SWING your sword to break the staff. LEAVE the cave, victorious. ")
                    c3 = c3.lower()
                    print ("")


                    if c3 == "take":
                        while True:
                            c4 = input("You reach forward and grasp the staff. Immediately, all the warmth and breath leaves your body. It is as though life itself is repulsed by you. Your flesh tightens around your bones, and your fingers begin to glow the same color as the eye at the tip of the staff. What do you do? RESIST the new sensation. EMBRACE the strange power. PRAY for divine intervention.")
                            c4 = c4.lower()
                            print("")


                            if c4 == "resist":
                                print("You attempt to resist the influence of the unholy staff. In respone, the emerald light emanating from the staff grows brighter. You hear a humming in your ears as you do all you can to pull your fingers away, but they seem to have a mind of their own and grasp tighter. You reach out with your second hand and try to peel your fingers away, but it is futile. You see a light grow under your hand, and as it grows number you realize it is the bones giving off the strange glow. The light spreads under your skin up your arm and into your chest. Once it reaches your head, your vision fades, and the humming grows more and more intense. You feel yourself crumble to ash, and your last thought is how cold it feels. GAME OVER. ")
                                break
                            elif c4 == "embrace":
                                print("You give in to the flow of energy, allowing it to course through you. You offer no resistance as psychic tendrils find their way through your body and into your mind. You still cannot breathe, and your mind goes numb, but you don't lose conciousness. You hold your eyes closed for a moment, accepting the new sensation. When you open them again, you are floating a few inches from the ground. You gaze through the cave, taking note of your new belongings. You point your staff at a pile of bones, and utter an incantation from a tongue you've never known, and the bones rattle. After about an hour of concentration, the pile lurches, a goliath of cobbled bodies rising to unlife. It silently approaches you, and kneels. You turn your gaze out of the cave mouth. The nearby village will provide you with many bones. You feel your mouth form a cold grin, and walk out into the night. GAME OVER.")
                                break
                            elif c4 == "pray":
                                print("You realize that touching the unholy artifact was a grave mistake. You try to drop it, but your fingers have wrapped themselves around the staff, and you are forced to watch as the staff begins to glow brighter. You squeeze your eyes closed, and as you feel your hand begin to grow cold and numb, begin reciting the lines of a prayer you remember hearing the villagers repeat. Nothing happens. Panicked, you repeat, trying to get the wording right, sure you pronounced something wrong. Your desperation grows as the sensation of nothingness continues creeping up your arm. Just as all seems lost, you finish what feels like your fifth recitation, and your eyes snap open. The sensation has fled your body, and is replaced with a fiery warmth. Your fingers have reversed, and it seems like the staff is now trying to escape your grasp. You tighten your grip in response, and hear a slight crack. A fragment of light, pure and brilliant, races up the staff, illuminating the cave. Suddenly, the staff explodes, sending shards of burnt wood and charred metal across the cave. You look at your now-empty hand, and see a fading scar, shaped similar to the symbol on the church in the village. You clench your fist, and make your way out of the cave and back towards the grateful villagers at the bottom of the hill, another job well done. GAME OVER.")
                                break
                            else:
                                print("Invalid input. Please try again. (hint: check your spelling!)")
                    
                    elif c3 == "swing":
                        while True:
                            c5 = input("Your sword cleaves through the staff. You hear a pop, and then the two halves of the sword drop to the ground. You hear a rumbling, then feel a rock clip your shoulder. You look up and realize the cave is collapsing! What do you do? RAISE your shield and make your way towards the exit. RUN as fast as you can for the cave mouth. DROP everything and flee for your life. ")
                            c5 = c5.lower()
                            print("")


                            if c5 == "raise":
                                print("You raise your shield just in time to block a large stone from hitting you directly on the head. You begin to move towards the cave mouth, blocking large stones from squishing you like a bug. The rumbling grows more intense, and you worry you won't make it out in time. You feel a massive rock bounce off your shield, and your shoulder goes numb from the impact. You're close enough to the exit, so you dive for safety. You hear a loud crash from behind you as the cave crumbles to dust. You try to get to your feet, but your leg is mangled under a large stone. You call for aid, and one of the villagers who was cautiously awaiting outside the cave comes to your aid. The grateful commoners take you back to their village, and do their best to heal you. You may not have come out unscarred, but you have done a good deed this day. GAME OVER.")
                                break
                            elif c5 == "run":
                                print("You dash for the exit of the cave. The ceiling of the cave lurches and cracks, threatening to crush you at any moment. Debris falls around you, and you can barely see through the dust being raised around you. Your speed compensates, though, and you dive out of the cave moments before a thunderous eruption of stone collapsing sounds behind you. You stand and dust yourself off. You turn back and see the cave is gone, as though it never existed in the first place. The only evidence remaining is a small crack between two boulders, with a fading green glow shimmering through. You turn and make your way down the hill, towards the celebrating villagers. Time to enjoy the taste of victory. GAME OVER. ")
                                break
                            elif c5 == "drop":
                                print("After a moment of stunned silence, you drop your sword and shield and make a desperate dash for the cave mouth. Stones rain around you, and you do your best to dodge them. Unfortunately, a larger stone clips your shoulder just as your foot lands on a smooth stone. You feel a crack in your ankle and tumble to the ground, pain racing up your leg. You look up to see a large piece of the cave ceiling detach and come hurtling towards you. What a shame. GAME OVER.")
                                break
                            else:
                                print("Invalid input. Please try again. (hint: check your spelling!)")
                    
                    elif c3 == "leave":
                        print("You turn and head out of the accursed cave. You make your way down the mountain and towards the eager villagers. The village elder, a portly old man, approaches you, with a hopeful look on his  face. You announce your victory, and the villagers cheer. They lead you into thheir village, and celebrations commence. The next day you leave the village on horseback, with a belly full of mead and a satchel full of gold. You turn back and look at the mountain for one last time. You think you see a flash of green light come from the top, near where the cave must be. You convince yourself it to be nothing more than a trick of the light, and turn back towards the road. GAME OVER.")
                        break
                    else:
                        print("Invalid input. Please try again. (hint: check your spelling!)")


                if c2 == "stab":
                    print("You put all your force into a stab, and lunge towards the lich. The sword passes through his robest, and goes all the way to the hilt. Time stops, as you look expectantly at the lich, waiting for him to begin dissolving into ash. This does not happen. Instead, he reaches out bony hand and grabs your neck. With surprising strength, he holds you at arms length, skeletal fingers tightening around your neck. Your feet kick at the thin air, finding no target as you squirm in desperation. With a smooth motion, he snaps your neck. You feel your whole body go limp as your breath catches in your throat, unable to find its way to your lungs. You dangle in the lich's grasp, and as your vision fades, you think of the villagers below. You failed, and soon, they will join you. GAME OVER. ")
                    break
                
                elif c2 == "bash":
                    while True:
                        c6 = input("You raise your shield as you hurtle towards the necromancer. You collide mid-air, and hammer into the ground. You hear loud crunching as the dry bones of the lich connect with the stony ground. You rise to your feet and look down at the pitiful sight. The necromancer's skeletal head looks up at you, emerald eyes losing some of their glow. The skull seems to contort into a smile, before a green vapor rises out of its mouth. The self-contained cloud races towards a colossal pile of bones behind you. They rattle violently, and you can only watch in horror as the unholy amalgamation begins to rise. A goliath, cobbled together from what must be dozens of corpses, stands before you. It raises a club-like arm, and slams it into the ground. A path of sharp rocks erupt from the ground in a path raciing towards you. What do you do? CHARGE the skeletal goliath. DIVE out of the way. CAST a spell. ")
                        c6 = c6.lower()
                        print ("")


                        if c6 == "charge":
                                print("With a determined shout, you charge towards the beast and the path or erupting stones. Directly in front of you, a large, jagged stone bursts from the ground. You have no time to redirect, and the stone plunges into your chest. Your sword and shield clatter to the floor, as your hands numbly try to feel your chest and push your body off. The goliath lumbers over, and for a moment, you think you'll be granted a quick, merciful death. Instead, you see a glow within the torso of the beast. One of the skeletons detaches, and levitates down. The abandoned robes and staff lying near the body of the lich fly over to this new skeleton, and you realize the lich never died, it simply reformed. It floats down before, and studies your body as the life is slowly draining and trickling down the jagged stone. It turns and takes note of the mess, before turning back towards you. It reaches a skeletal finger towards where your body meets stone, and touches the wound. It feels like your blood is raised to an  instant boil, and you scream in pain. You squirm, but no avail. The lich cackles as it walks away. You have been cursed to stay here, suspended, not quite alive but not quite dead. You have been reduced into a symbol of the lich's cruelty. GAME OVER. ")
                                break


                        elif c6 == "dive":
                                print("You dive, and the erupting rocks miss you by a hair. You clamber to your feet just in time to see the abomination before you, arm raised. You have no time to react before it brings its arm crashing down. The world goes black, and you never even hear the impact. Oh well, at least you died fighting. GAME OVER.")
                                break
                        elif c6 == "cast":
                                while True:
                                    c7 = input("You draw upon the winds of magic, and thrust your hands towards the ungodly horror. The erupting stones stop in place, and the goliath looks up, silent rage written on what passes for its face. It begins charging towards you with frightening speed. With a hand motion, you rip a large stalactite from the ceiling and hurl it at the beast. The sharp stone tears through the mass of bones and pins the beast to the ground. The pile of bones dissassembles, discarding shattered ribcages and broken skulls. The remaining bones assemble themselves into a small army, all with same glowing green eyes you saw in the lich. The horde charges you. What do you do? CALL upon magic. CHARGE with your sword raised. FLEE as fast as you can.")
                                    c7 = c7.lower()
                                    print("")


                                    if c7 == "call":
                                        print("You call out to the forces of magic, attempting a similar feat to the one used against the goliath, but no answer comes. In horror, you realize all your mana was spent on that earlier demonstration. You don't have enough time to raise your sword before the horde reaches you. They collide upon you like a wave, and you feel dozens of skeletal hands begin to tear you apart. Your screams will not be heard this day, and you die alone. GAME OVER.")
                                        break


                                    elif c7 == "charge":
                                        print("Your trusty blade has never failed you. You charge the unholy horde, and begin to swing your sword with renewed fervor. You fight for your life against waves of skeletons. After a difficult battle, you stand victorious. You crush the last skull under your foot, ensuring the lich has no more hosts. Your grip on your sword loosens, and you sheathe it. You are heavily wounded, but you'll live. You stumble out of the cave and down the mountain. Villagers surround you, and as your vision fades to black, you collapse into their arms. You wake the next morning in a bed in the inn. You are bandaged, and there is a balm on a wound in your chest. Thhe door quietly opens, and a beautiful barmaid slides in. When she sees you're awake, she smiles, and curtsies, before placing a bowl of stew on your lap and chhecking your bandages. 'The fight  was clearly worth it', you think, as your eyes meet while she checks a bandage on your forehead. GAME OVER.")
                                        break


                                    elif c7 == "flee":
                                        print("You drop your sword, and before you even hear it hit the ground you've turned and begun runnning towards the mouth of the cave. You hear a cacophany behind you as the horde of skeletons surge behind you. As you race down the mountain, you try and gain distance, but it is hopeless. They are tireless, and unbothered by the thorns and bugs that slow you down. Too late, you realize you've drawn too close to the village, and the skeletons finally leave you alone. You have no choice but to continue running, and attempt to shut out the sounds of the tidal wave that is the undead horde courses through the town. As the screams fade, you are forced to continue running. The silence is worse. You will have to answer for your cowardice some day. GAME OVER.")
                                        break


                                    else:
                                        print("Invalid input. Please try again. (hint: check your spelling!)")
                        else:
                            print("Invalid input. Please try again. (hint: check your spelling!)")
                else:
                    print("Invalid input. Please try again. (hint: check your spelling!)")
    if c1 == "magic":
        while True:


            c8 = input("You make a motion with your hand, and a barrier shimmers to life around you. The lich spreads his arms, and tendrils of dark energy tear out from within his robes. You push your hands outwards, using the bubble of protection to catch and contain the magical projectiles, condensings into a small black-and-white ball of cracklling energy. You make a fist, draw back, and punch forward, sending the ball blitzing back at its sender. The ball collides with the lich's head, cleaving off half of his skull. He reaches up, feeling the damage, then turns to you. With what remains of his jaw, he lets out a screech, echoing throughout the cave. Eery blue energy rises up from the floor and race into nearby piles of bones. Four fully-formed skeletons rise, clad in armor that must have been brilliant decades ago. The undead honor guard raise their pikes and march towards you in formation, surrounding you. What do you do? Trust in MAGIC. CHARGE the lich. DUEL the skeletal guards.")
            c8 = c8.lower()
            print ("")


            if c8 == "magic":
                print("You attempt to call upon the winds of magic, but hear no answer. The lich cackles as you both realize you're totally out of mana. You don't have the time to draw your sword before the guards are upon you, and in unison, they thrust their pikes into your body. You try to squirm, but to no avail. They lift your body high above their heads with the pikes, before collectively pulling back. Your body tumbles to the ground. The last thing you see is the hollow boots marching back towards their unholy master. GAME OVER.")
                break


            if c8 == "charge":
                while True:
                    c9 = input("You try to charge the lich, sword raised. Two skeletal arms shoot out, and the guards catch you, throwing you back into the circle. You land on your knees, four rusty pikes at your neck. The lich grins, And raises a hand towards you. 'Swear fealty to me, and you may keep your putrid life. Refuse, and give your bones over to me.'. What do you do? Swear FEALTY. REFUSE the heretic.")
                    c9 = c9.lower()
                    print ("")


                    if c9 == "fealty":
                        print("Your breath catches in your throat as you struggle to find the words. Finally, you submit, and lower your head. You see the lich descend, his feet touching the ground as he glides towards you. He reaches a skeletal hand forward and grasps your neck. For a moment you feel a rush of cold spread through your body. You have been marked. Betrayal is out of the question. The lich commands you to rise to your feet. He sends you back out of the village. The villagers approach, hopeful that you've been succesful in saving them from the lich's machinations. You cannot meet the village elder's gaze, and out of the corner of your eyes, you see quick blurs of faint blue light. You open your mouth to try and speak but no words come out. The villagers are concerned, and some come forwards, attempting to offer aid. It is no use. Here, outside the village walls, they are undefended. When the skeletons begin appearing from the shadows, you can do nothing but watch. It is a massacre. Unarmed and surrounded, the villagers are quickly cut down, their silent executioners ruthlessly efficient. It's over in under a minute, and the mangled bodies are heaped together. As you watch, glasy-eyed, you feel a cold, skeletal hand on your shoulder. A robed arm drops a map into your hands, and points forward. You are compelled forward, a helpless, silent herald of an undead horde. This village is the first of what is sure to be many, and you can do nothing to slow the tide of undeath. GAME OVER.")
                        break
                    elif c9 == "refuse":
                        print ("Your life is on the line, but your soul is not. You cannot give in, and refuse the unholy abomination. You cannot hear, but you see the lich mouth the word 'harvest'. You feel the pikes pierce your neck, and your vision goes black. GAME OVER.")
                        break
                    else:
                        print("Invalid input. Please try again. (hint: check your spelling!)")


            elif c8 == "duel":
                while True:
                    c10 = input("You draw your sword and shield, and face the approaching skeletons. With a flick of your blade, you break the tip of one guard's pike, and whirl around in time to deflect the thrust of another's. The guards are efficient and skilled, but not enough to best you. You become a blur of motion, severing bones and cracking weapons. Finally, the blue light drains from last guard's eyes. You turn to face the lich, who has his arm's raised once more. Vile green lightning leaps between his fingers. What do you do? THROW your sword. RAISE your shield. PREPARE a counterspell.")
                    c10 = c10.lower()
                    print ("")


                    if c10 == "throw":
                        print ("You hurl your sword at the undead wizard at the same time he lowers his hands towards you. Arcs of accursed energy hit your body at full force, and you feel your chest burning away. However, your blade found it's mark. The sword managed perfectly sever the brittle skull from the lich's head. The lich crumples in a heap of ash, but the damage to your body is too severe. You clutch your chest as your life fades away. You are consoled in your last moments with the knowledge that the villagers are safe. GAME OVER.")
                        break
                    elif c10 == "raise":
                        while True:
                            c11 = input("You raise your shield just in time to catch the torrent of terrible energy. Waves of unholy power break against your shield, and you push forward weakly. Each step takes all your effort, but you advance despite the force against you. The magic stops, and you look to see the lich, fear plastered across it's skinless face. It begins to ascend in an attempt to escape. What do you do? REACH out towards the lich. LUNGE upwards with your sword. THROW your blade. ")
                            c11 = c11.lower()
                            print ("")


                            if c11 == "reach":
                                print ("Your arm shoots out and grabs the lich's skeletal ankle. With force that surprises even you, you pull and slam the body of the lich down onto the ground. His body shatters. With a definitive stomp, you crush the lich's skull. You sheathe your blade, and confidently stride out of the cave. The villagers begin to cheer when they see your approach. The festivities commence, and you rejoice with them late into the night. You ride out the next morning, content with your victory. GAME OVER.")
                                break
                            if c11 == "lunge":
                                print ("You leap upwards, sword drawn. The lich barely has time to react before you're on him, slashing and tearing. You crash into the ground, the lich quickly disassembling beneath you. A pain shoots up your side, and you look down to find the sharp end of a rib jutting out from your torso. Clutching the wound, you descend the mountain, ushered by cheering villagers. As you sit outside the hut of the town apothecary and patch yourself up, the villagers perform a traditional dance around a pyre built in your honor. Two barmaids keep stealing glances and giggling when you notice. You've brought peace and safety to this village, at least for now. Time to enjoy it. GAME OVER. ")
                                break
                            if c11 == "throw":
                                print ("You hurl your blade at the retreating lich. It lands between it's ribs. It makes an unnatural screech of pain, but continues asacending and quickly disappears out of a hole in the top of the cave. You make your way back down the mountain and towards the village. The villagers rejoice at the departure of the lich, but there are whispers that it might return someday. You are given a pouch of gold in thanks and sent on your way. GAME OVER.")
                                break
                    elif c10 == "prepare":
                        print("You make a motion with your hands, preparing to counter the lich's display of magic. Too late, you remember you are out of mana, and your last memory is of your eyes being filled with a terrible blue light as the lich's spell saps your life from out of you. GAME OVER.")
                        break
                    else:
                        print("Invalid input. Please try again. (hint: check your spelling!)")
            else:
                print("Invalid input. Please try again. (hint: check your spelling!)")
    if c1 == "talk"
        while True:
            c12 = input("You raise your hands. 'WAIT!', you call out. Surprised, the lich stops his incantation, and the green flame forming around his skeletal hands fizzles out. Despite the ceasefire, you can tell you only have moments to make a move. What do you do? BARGAIN for peace. Swear FEALTY to the powerful lich. INSULT the abomination. ")
            c12 = c12.lower()
            print("")


            if c12 == "bargain":
                print("You reach for a pouch of gold on your belt and toss it in the direction of the lich. 'There's more where that came from', you say, 'the king just wants his land left alone. He will pay more if you go to the other side of the mountain and bother the kingdom of his brother.' A cold grin makes its way across the lich's face. 'I care not for gold or rubies,' utters a quiet voice, 'I only value bones.' Too late, you realize he has summoned four skeletons behind you, and they quickly take hold of your arms, forcing you to your knees. The stone floor beneath you seems to shimmer before igniting, engulfing you in flames. You feel the intense heat pick the flesh from your bones, leaving your lower half bare as it makes its way up your body. Down the hill, the villagers hear your screams. They shake their heads, disappointed. Perhaps the next adventurer will have more success. GAME OVER.")
                break


            elif c12 == "fealty":
                print("You slowly slide your sword from its scabbard and take a knee before the lich, raising your blade above your head in offering. 'I am nothing before your majesty. What is left of my life, I give to you.' The lich is pleased by your show of submission. He descends before you, and places a skeletal hand on your head. You feel your skin growing cold, and your hair drying and falling out. There is a flash of heat on your temple as a glowing symbol is bored into your skull. 'Rise,' commands a voice from within your mind, and you are compelled to obey. 'Toys must be tested,' comes the voice. 'Bring me the bones of those pitiful villagers.' You make your way down the mountain, and the villagers surge to meet you. Eager, the village elder approaches you, seeking news of your quest. He draws back when he sees your sword drawn. You look up, and see a single figure in the night sky, eery green light contrasting it from the inky black. Your grip on your sword tightens, and you advance. GAME OVER.")
                break


            elif c12 == "insult":
                print("You hurl a string of blasphemous obscenities at the unholy lich. The lich folds its arms, and if it still had a face, you're certain it's eyebrows would be raised. Once you've expended your vocabulary and circled back to lines you've already used, the lich holds up a hand. Two large stones detach from the ceiling, and before you can react, they've met the floor, pinning your limbs and twisting them in unnatural angles. The lich approaches, and a skeletal finger grasps your tongue. You feel your mouth begin to heat up, hotter than a furnace. You are not granted a swift death, rather you suffer for hours, pinned in an uncomfortable position as your tongue burns and rots. Offfending powerful liches in their own home is never a good idea, why did you think that would work? GAME OVER.")
                break


            else:
                print("Invalid input. Please try again. (hint: check your spelling!)")

r/learnpython • • Jun 28 '26

I found another way to find duplicates without converting to a set. Is this good?

0 Upvotes
def findduplicates(listf):
    duplicates = []
    duplicate = 0
    for i,v in enumerate(listf):
        for index,value in enumerate(listf):
            if v == value and not i == index:
                duplicates.append(v)
                listf.pop(index)
                duplicate = 1
            else:
                continue
        if duplicate == 1:
            print("Duplicate(s) were found:")
            for i,v in enumerate(duplicates):
                print(v)
        else:
            print("No duplicates found.")


listwithduplicates = [1,3,3,2]
listwithoutduplicates = [1,7,9,8]
listwithduplicates2 = [1,1,3,7,9,9]
listwithoutduplicates2 = [7,9,4,6,8]


findduplicates(listwithduplicates)
findduplicates(listwithoutduplicates)
findduplicates(listwithduplicates2)
findduplicates(listwithoutduplicates2)

r/learnpython • • Dec 08 '25

What should I learn!?

0 Upvotes

Hey guys I am one of those beginners with big dreams

Straight to point I wanna make ADULT VN But rn I have to learn python for the basic coding

I tried one coaching earlier but he taught me everything useless instead of what I really need I don't wanna mess up again and give him right information but also I can't just say I wanna make adult VN..he would probably kick me out

Can you guys tell me what should I learn? To make something like eternum or projekt passion..chatgpt pointed few things

Variables and branching logic Functions (for minigames) Data structures

It would be a great help if you guys can add other things as well..

Edited: Anyone who comes here searching for answers that I needed...here is what I learned

-Dont leave anything for later you will need it!

  • CS50P from Harvard is your go through (it's completely free and would take about 15 weeks or less) -After you complete CS50P read and study these.https://feniksdev.com/navigation/..

And after this you are capable of making complex games in renpy Thanks to all who helped me in the comments 😄


r/learnpython • • Jul 30 '25

I want to learn pyhon

0 Upvotes

Hello everyone. I would like you to leave me some project ideas to help me learn Python better — especially in areas like automation, web development, and so on.


r/learnpython • • Feb 06 '26

How to actually write it

0 Upvotes

I understand python as in I know what loops are valuables input ect ect. But I don't know how to actually use it to make for example a calculator what do I do


r/learnpython • • May 09 '25

Python slicing, a[len(a)-1:-1:-1]

0 Upvotes

Hi, basic python question.

why this doesnt work?

a="hello"
a[len(a)-1:-1:-1] 
#a[start:stop:step] start index 4, stop index -1 (not inclusive so it will stop at 0), step -1 

All ai's saying Gibberish.


r/learnpython • • Jun 12 '26

How to learn OOP

0 Upvotes

I started to learn OOP and when I use it, it is a little bit confusing. Especially when initializing. Most of the time I pass. Is there any way you recommend me to understand OOP? to familarize it.


r/learnpython • • Oct 15 '26

Where to start

0 Upvotes

Hello, I am trying to pick up a hobbie. Can someone point me in the right direction.


r/learnpython • • Aug 24 '26

My Self-Imposed Rule to Escape AI Micromanagement and Learn Python Properly

1 Upvotes

I have been working my way through Python Crash Course and just finished up chapter 4 moving into conditional tests, but I noticed a bad habit creeping in where I was leaning on AI way too much for micromanagement and minor steps instead of letting myself struggle through the code. To fix this, I am setting up a strict personal rule starting today. I am only allowed to use AI for direct, core coding help and roadblocks on my exercises, and zero AI usage for trivial hand holding. Also, if I do slip up and use it for micromanagement, I have to log the exact example and post it here so others can keep me honest. Has anyone else had to put hard boundaries on their AI tool usage while learning programming, and how did you structure your rules to make sure you were actually building things yourself?