r/learnpython • • Aug 24 '26

I need help pls

0 Upvotes

How can I remove in my python script the Windows bar at the top to drag and close please


r/learnpython • • Aug 24 '26

Ask Anything Monday - Weekly Thread

0 Upvotes

Welcome to another /r/learnPython weekly "Ask Anything* Monday" thread

Here you can ask all the questions that you wanted to ask but didn't feel like making a new thread.

* It's primarily intended for simple questions but as long as it's about python it's allowed.

If you have any suggestions or questions about this thread use the message the moderators button in the sidebar.

Rules:

  • Don't downvote stuff - instead explain what's wrong with the comment, if it's against the rules "report" it and it will be dealt with.
  • Don't post stuff that doesn't have absolutely anything to do with python.
  • Don't make fun of someone for not knowing something, insult anyone etc - this will result in an immediate ban.

That's it.


r/learnpython • • Aug 24 '26

how to make my code work in minecraft

0 Upvotes

dont question my code too much, i just started python and watched a 1 hour coding with mosh video to understand some of the basics.

all it does is move my mouse around while i hold g. but it doesnt work when i go into minecraft, and i assume, any program that locks my mouse.

what do i do?

import random
import keyboard
import pyautogui
import pyscreeze
from pyautogui import mouseInfo, click
while True:
    if keyboard.is_pressed('g'):
        pyautogui.moveTo(random.randint(0, 2600), random.randint(0, 2600))
    if keyboard.is_pressed('q'):
        break

r/learnpython • • Aug 23 '26

Feedback On Fancy Text Printing

2 Upvotes

I've been learning python for years, but I rarely show my code to anyone. I enjoy showing the results of my code to people, but I don't know too many programmers IRL who can give me feedback. I know I have a habit of not commenting enough, but hopefully this is readable. It's my attempt at making text print like in video games (Earthbound, for example.)

Am I doing anything particularly inefficient? I want to know how I can improve this.

from time import sleep
import sys

#Theoretically there could be other wait times for punctuation
punc_default = {" ": 0, ",": 0.25, ".": 0.4, "!": 0.5, "?": 0.5}

def txt(string,time=0.05,punctimes=punc_default):
    for char in string:
        sys.stdout.write(char)
        sys.stdout.flush()
        if char not in punctimes: sleep(time)
        else: sleep(punctimes[char])

txt("Who lives in a pineapple under the sea? Spongebob Squarepants! qwertyuiop.")

r/learnpython • • Dec 02 '24

Can someone explain to me how do decorators work?

38 Upvotes

I have been coding for quite a while (2-3yrs) and use to mostly just let it go but I need to know how these things work. Also what was the need for this that could not possibly be done without decorator.

p.s. I did try chatGPT I did not understand


r/learnpython • • Oct 10 '24

can someone explain lambda to a beginner?

107 Upvotes

I am a beginner and I do not understand what lambda means. Can explain to me in a simple way?


r/learnpython • • Jun 13 '24

Rock Paper Scissors (First Personal Project)

16 Upvotes

Well, you may start seeing me post frequently as I continue to progress in Python! In the previous post I mentioned "project time". I spent a little time to build Rock, Paper, Scissors in a way I know to make it work. Now, that I know that this works, it may be time to refactor it, because the code seemed repetitive and very lengthy, but I want your guys thoughts on it.

==================================================================

# Rock, Paper, #Scissors
import random

choices = ['rock', 'paper', 'scissors']
player_score = 0
computer_score = 0

print('Welcome to Rock, Paper, Scissors!')

while True: 
    #prompt the user to choose between rock, paper, or scissors.
    player_input = input('\nEnter Rock, Paper, or Scissors: ')
    print("Enter 'q' to quit. ")

    # break the loop if player types 'q'
    if player_input.lower() == 'q':
        break

    #computer generate a random choice of rock, paper, or scissors. 
    computer_choice = random.choice(choices)

    # player and computer chooses same option, its a draw.
    if player_input.lower() == computer_choice:
        print('DRAW!')

        # if player chooses rock, and computer chooses paper.
    elif player_input.lower() == 'rock' and computer_choice == 'paper':
        computer_score += 1
        print('Paper covers rock, Computer wins! ')

        # if player chooses rock, and computer chooses scissors.
    elif player_input.lower() == 'rock' and computer_choice == 'scissors':
        player_score += 1
        print('Rock beats Scissors, Player wins! ')

        # if player chooses paper, and computer chooses scissors.
    elif player_input.lower() == 'paper' and computer_choice == 'scissors':
        computer_score += 1
        print('Scissors cut paper, Computer wins! ')

        # if player chooses paper, and computer chooses rock.
    elif player_input.lower() == 'paper' and computer_choice == 'rock':
        player_score += 1
        print('Paper covers Rock, Player wins! ')

        # if player chooses scissors, and computer chooses rock.
    elif player_input.lower() == 'scissors' and computer_choice == 'rock':
        computer_score += 1
        print('Rock beats scissors, Computer Wins! ')

        # if player chooses scissors, and computer chooses paper.
    elif player_input.lower() == 'scissors' and computer_choice == 'paper':
        player_score += 1
        print('Scissors cut paper, Player wins! ')

    else:
        # if computer chooses rock, and player chooses paper.
        if computer_choice == 'rock' and player_input.lower() == 'paper':
            player_score += 1
            print('Paper covers rock, Player wins! ')

        # if computer chooses rock, and player chooses scissors.
        elif computer_choice == 'rock' and player_input.lower() == 'scissors':
            computer_score += 1
            print('Rock beats Scrissors, Computer wins! ')

        # if computer chooses paper, and player chooses scissors.
        elif computer_choice == 'paper' and player_input.lower() == 'scissors':
            player_score += 1
            print('Scissors cut paper, Player wins!')

        # if computer chooses paper, and player chooses rock.
        elif computer_choice == 'paper' and player_input.lower() == 'rock':
            computer_score += 1
            print('Paper covers Rock, Computer wins!')

        # if computer chooses scissors, and player chooses paper.
        elif computer_choice == 'scissors' and player_input.lower() == 'rock':
            computer_score+= 1
            print('Scissors cut paper, Computer wins! ')
        # if computer chooses scissors, and player chooses paper.
        elif computer_choice == 'scissors' and player_input == 'paper':
            computer_score += 1
            print('Scissors cut paper, Computer wins! ')


# print total score. 
print ('\nGAME OVER!')
print (f'Player Score = {player_score} Computer Score = {computer_score}')
if player_score > computer_score:
    print('Player wins the game!')

elif player_score == computer_score:
    print('DRAW!')

else:
    print('Computer Wins the game!')

r/learnpython • • Oct 10 '23

Best way to Create responsive Modern GUIs in Python ?

18 Upvotes

In my opinion PyQt5 (or pyside6 no difference i think ) is the best option because it has its own QT designer + Ide but I dont how we can make it more modern ,

I m building a windows app as a side project i need some suggestions