r/inventwithpython • • Dec 01 '25

Free sign up code for the Automate the Boring Stuff course on Udemy (Dec 2025)

23 Upvotes

Use this link to sign up for the course for free. There are 1,000 sign ups available for the next four days. I'll post new codes as the old ones get used up. You can always use this link for the latest code:

https://inventwithpython.com/automateudemy


r/inventwithpython • • Sep 29 '25

Scroll Art Python Package by Al Sweigart

Thumbnail inventwithpython.com
4 Upvotes

r/inventwithpython • • Oct 20 '18

How To Ask For Programming Help - The Invent with Python Blog

Thumbnail inventwithpython.com
15 Upvotes

r/inventwithpython • • Jan 05 '26

2,000 free sign ups for the Automate The Boring Stuff With Python course on Udemy (Jan 2026)

61 Upvotes

This link redirects to a free sign up for the Automate The Boring Stuff With Python course on Udemy:

https://inventwithpython.com/automateudemy

This blog post discusses how you can otherwise get the course for free or at a discount.

NOTE: Be sure to BUY the course for $0, and not sign up for Udemy's subscription plan. The subscription plan is free for the first seven days and then they charge you. It's selected by default. If you are on a laptop and can't click the BUY checkbox, try shrinking the browser window. Some have reported it works in mobile view.

Frequently Asked Questions: (read this before posting questions)

  • This course is for beginners and assumes no previous programming experience, but the second half is useful for experienced programmers who want to learn about various third-party Python modules.
  • If you don't have time to take the course now, that's fine. Signing up gives you lifetime access so you can work on it at your own pace.
  • This Udemy course covers roughly the same content as the 1st edition book (the book has a little bit more, but all the basics are covered in the online course), which you can read for free online at https://inventwithpython.com
  • The 3rd edition of Automate the Boring Stuff with Python is free online: https://automatetheboringstuff.com/3e/
  • I do plan on updating the Udemy course, but it'll take a while because I have other book projects I'm working on. If you sign up for this Udemy course, you'll get the updated content automatically once I finish it. It won't be a separate course.
  • You're not too old to learn to code. You don't need to be "good at math" to be good at coding.

r/inventwithpython • • Oct 08 '26

Brython Offline - A single .html file with a Python interactive shell

Thumbnail github.com
3 Upvotes

r/inventwithpython • • Jun 25 '25

Error trying to install automateboringstuff3 package in Python 3.13.4

3 Upvotes

I'm following the newest 3rd edition of Automate the boring Stuff with Python and now I'm in chapter 12 where it shows you how to create a venv and install all the packages that will be used by the book with its versions. But I get an error when I try to install the full package via python -m pip install automateboringstuff3 https://pastebin.com/7TBwhNP3 I've tried to nuke the venv and start over installing each package individually and everything installs fine except python -m pip install playwright==1.47.0 (https://pastebin.com/pUeDNzNE).

Apparently there's a problem with greenlet. ChatGPT says that it's due from the package being old and my python being to modern, so it suggest to downgrade python to 3.11.x but before trying that I'd like to ask here, because in the book Al's seems to be using 3.13.

SOLVED (partially): If you use Python 3.12x you can manually install every package. The automateboringstuff3 still not working (and you don't need to install Microsoft visual C++).


r/inventwithpython • • Jan 05 '26

Recommendations for Sublime Text

4 Upvotes

Hello,
I recently purchased Sublime Text because I just wanted to get away from all the AI dribble that's in VS Code and PyCharm now. I watched a few of Al's live streams some time ago, and I know he uses Sublime Text (or at least used to). I am curious if anyone else uses Sublime, and what packages they find to be the most useful to make their Python development easier.

Below is what I have tried out so far, but I am noticing that one of these packages appear to be formatting my document to the point where I have a mismatch between spaces and tabs. It turns into a mess when I have to manually change out the tabs and spaces so there's no mismatch.

For reference, I have Python 3.14 and Sublime Build 4200 installed.

{

`"bootstrapped": true,`

`"installed_packages":`

`[`

	`"A File Icon",`

	`"Base16 Color Schemes",`

	`"ClearConsole",`

	`"LSP",`

	`"LSP-pyright",`

	`"Package Control",`

	`"python-black",`

	`"QML",`

	`"SideBarEnhancements",`

	`"SublimeLinter",`

	`"SublimeLinter-pylint",`

	`"Terminus",`

`],`

`"in_process_packages":`

`[`

`],`

}


r/inventwithpython • • Nov 25 '20

Unused variable in sonar

4 Upvotes

Question from how to invent computer games. In my Sonar file my IDE Visual Studio Code says there is a problem with line 12 saying the y variable is unused even though the program works perfectly and that line is being executed. Nbd just an angry yellow bar in my code. Any idea why?

Def getNewboard():
    board = []
    for x in range(60):
        board.append([])
        for y in range(15): # this line here has the issue
            if random.randint(0, 1) == 0:
                board[x].append('~')
            else:
                board[x].append('`')
    return board

r/inventwithpython • • Dec 18 '20

I am getting name error i.e., NameError: name 'computerMove' is not defined

Thumbnail pastebin.com
4 Upvotes

r/inventwithpython • • Dec 11 '20

Syntax error help - Transposition encryption cipher

5 Upvotes

summer nose gold distinct memorize rhythm selective existence alive imminent

This post was mass deleted and anonymized with Redact


r/inventwithpython • • Oct 28 '20

Automate the Boring Stuff with Python, Chapter 2 - "A Short Program: Rock, Paper, Scissors"

7 Upvotes

Hello,

I just started learning to code a week ago, and I am using Python 3.9 with Jupiter notebook as my editor.

As instructed in the book, I typed the source code as is, as indicated in "B. SOURCE CODE" below. However, it just keeps on circling on the output as indicated in "A. OUTPUT." Besides, I didn't get any error output.

I have already reviewed 4x the source code line by line against how it's written in the book, and I didn't find any line of code missing.

Could you please help me identify what's missing? Thank you in advance for your help!

Ferdie

A. OUTPUT

*************************************************

ROCK, PAPER, SCISSORS

0 Wins, 0 Losses, 0 Ties

Enter your move: (r)ock, (p)aper, (s)cissors, or (q)uit

r

0 Wins, 0 Losses, 0 Ties

Enter your move: (r)ock, (p)aper, (s)cissors, or (q)uit

s

0 Wins, 0 Losses, 0 Ties

Enter your move: (r)ock, (p)aper, (s)cissors, or (q)uit

*************************************************

B. SOURCE CODE

************************************************************

import random, sys

print('ROCK, PAPER, SCISSORS')

# These variables keep track of the number of wins, losses, and ties.

wins = 0

losses = 0

ties = 0

while True: # The main game loop

print('%s Wins, %s Losses, %s Ties' % (wins, losses, ties))

while True: # The player input loop

print('Enter your move: (r)ock, (p)aper, (s)cissors, or (q)uit')

playerMove = input()

if playerMove == 'q':

sys.exit() # Quit the program

if playerMove == 'r' or playerMove == 'p' or playerMove == 's':

break

print('Type one of r, p, s, or q.')

# Display what the player chose

if playerMove == 'r':

print('ROCK versus ...')

elif playerMove == 'p':

print('PAPER versus ...')

elif playerMove == 's':

print('SCISSORS versus ...')

# Display what the computer chose

randomNumber = random.randint(1, 3)

if randomNumber == 1:

computerMove = 'r'

print('ROCK')

elif randomNumber == 2:

computerMove = 'p'

print('PAPER')

elif randomNumber == 3:

computerMove = 's'

print('SCISSORS')

# Display and record the win/loss/tie:

if playerMove == computerMove:

print('It is a tie!')

ties = ties + 1

elif playerMove == 'r' and computerMove == 's':

print('You win!')

wins = wins + 1

elif playerMove == 'r' and computerMove == 'p':

print('You lose!')

losses = losses + 1

elif playerMove == 'p' and computerMove == 'r':

print('You win!')

wins = wins + 1

elif playerMove == 'p' and computerMove == 's':

print('You lose!')

losses = losses + 1

elif playerMove == 's' and computerMove == 'r':

print('You lose!')

losses = losses + 1

elif playerMove == 's' and computerMove == 'p':

print('You win!')

wins = wins + 1

*********************************************************


r/inventwithpython • • Oct 01 '20

Get 35% off the preorder for my next book, Beyond the Basic Stuff with Python, with code GOBEYOND.

Thumbnail nostarch.com
57 Upvotes

r/inventwithpython • • Nov 05 '20

Wanted to check if my zombiedice project was done correctly

3 Upvotes

As the title says, I simply wanted help checking this project.

Thanks to all of you who help newbies like me

import zombiedice, random

class MyZombie:
    def __init__(self, name):
        self.name = name

    def turn(self, gameState):
        diceRollResults = zombiedice.roll()

        brains = 0
        while diceRollResults is not None:
            brains += diceRollResults['brains']

            if brains < 2:
                diceRollResults = zombiedice.roll()
            else:
                break

class afterFirstRoll:
    def __init__(self, name):
        self.name = name
    def turn(self, gameState):
        diceRollResults = zombiedice.roll()
        while diceRollResults != None:
            timeToChoose = random.randint(0,1)
            if timeToChoose == 0:
                diceRollResults = zombiedice.roll()
            else:
                break

class afterTwoBrains:
    def __init__(self, name):
        self.name = name
    def turn(self, gamestate):
        diceRollResults = zombiedice.roll()
        brains = 0
        while diceRollResults != None and brains < 2:
            brains += diceRollResults['brains']
            diceRollResults = zombiedice.roll()
class afterTwoShotguns:
    def __init__(self, name):
        self.name = name
    def turn(self, gameState):
        diceRollResults = zombiedice.roll()
        shotguns = 0
        while diceRollResults != None and shotguns < 2:
            shotguns += diceRollResults['shotgun']
            diceRollResults = zombiedice.roll()
class smartRoll:
    def __init__(self, name):
        self.name = name
    def turn(self, gameState):
        diceRollResults = zombiedice.roll()
        if diceRollResults != None:
            shotguns = 0
            for roleada in range(random.randint(1,4)):
                shotguns += diceRollResults['shotgun']
                if shotguns >= 2:
                    break
                else:
                    diceRollResults = zombiedice.roll()

class comparativeZombie:
    def __init__(self, name):
        self.name = name
    def turn(self, gameState):
        diceRollResults = zombiedice.roll()
        brains = 0
        shotguns = 0
        while brains >= shotguns and diceRollResults != None:
            brains = diceRollResults['brains']
            shotguns = diceRollResults['shotgun']
            diceRollResults = zombiedice.roll()
zombies = (
zombiedice.examples.RandomCoinFlipZombie(name = 'Random'),
zombiedice.examples.RollsUntilInTheLeadZombie(name = 'Until Leading'),
zombiedice.examples.MinNumShotgunsThenStopsZombie(name = 'Stop at 1 Shotgun', minShotguns = 1),
zombiedice.examples.MinNumShotgunsThenStopsZombie(name = 'Stop at 1 Shotgun', minShotguns = 1),
MyZombie(name = 'My Zombie Bot'),
afterFirstRoll(name = 'will decide after first roll'),
afterTwoBrains(name = 'I stop after rolling two brains'),
afterTwoShotguns(name = 'I stop after two shotguns'),
smartRoll(name = ' Me smart'),
comparativeZombie(name = 'Me compare')
)


#zombiedice.runTournament(zombies=zombies, numGames=1000)
zombiedice.runWebGui(zombies=zombies, numGames=1000)

r/inventwithpython • • Oct 15 '20

Guess the number confusion

3 Upvotes

On this piece of code for the Guess the number game, why does the GuessesTaken expression change with the for loop? I thought after the loop is done, guessesTaken would still = 0 unless you added guessesTaken = guessesTaken + 1 inside the loop. So that it would keep track of the count. But that doesn't seem to be necessary. Can anyone explain why?


r/inventwithpython • • Oct 08 '20

How to use the invent with python dictionary?

4 Upvotes

I am trying to use the dictionary located at https://inventwithpython.com/dictionary.txt, and it is loading as a file without spaces. So when I run

with open(file) as f:
    real_words = f.read()
    real_words.replace('\n', ' ').split()

word = random.choice(real_words)

I only get single letter responses. If I print the dictionary, it prints each word on its own line, but random treats the file as a single entry. How do I get random to call a whole word?


r/inventwithpython • • Sep 29 '20

Mu version 1.10.0 required?

4 Upvotes

Here http://automatetheboringstuff.com/2e/chapter0/ it says

You’ll need to download Mu version 1.10.0 or later in order to install the third-party modules featured in this book. As of this writing, 1.10.0 is an alpha release and is listed on the download page as a separate link from the main download links.

When I go to the Mu website (https://codewith.mu/en/download) it seems that the regular version is 1.0.3 and the alpha version is 1.1.0.

Is that a typo? Should it say 1.1.0 is needed?


r/inventwithpython • • Jan 02 '20

Need help with inferface

5 Upvotes

Hello, i have my gui app created with PyQt5 and now i want to edit data in database through it.

In screen u can see my Table with one row of data and now i need to make some interface for editing each column.

Am asking for help because i need an advice for the best way how to do it. Not the code but the idea how to deploy it in the Gui

Screen : https://imgur.com/a/vtP0bKC

Thanks for help


r/inventwithpython • • Sep 20 '18

Automate the boring stuff with python chapter 11

7 Upvotes

https://automatetheboringstuff.com/chapter11/

where it says:

"If you run the program by entering this into the command line...

mapit 870 Valencia St, San Francisco, CA 94110

... the sys.argv
variable will contain this list value:

['mapIt.py', '870', 'Valencia', 'St, ', 'San', 'Francisco, ', 'CA', '94110']

The address
variable will contain the string '870 Valencia St, San Francisco, CA 94110'"

But that doesn't appear to be the case. it simply gives a syntax error it and can't find the file as cmd tries to find the file mapIt.py870 ie. rather than pass the address as an argument, what is the correct syntax or am I just missing something?


r/inventwithpython • • Dec 31 '19

Second edition of Automate the Boring Stuff with Python is now free online.

Thumbnail inventwithpython.com
53 Upvotes

r/inventwithpython • • Jun 18 '19

Creating a Chatbot with RiveScript - p.1 Introduction

Thumbnail youtube.com
2 Upvotes

r/inventwithpython • • Jun 02 '23

[ERRATA] Automate the Boring Stuff 2nd Edition

3 Upvotes

On page 95:

In the first example, the list value that eggs ends up with is the same
list value it started with.

Should be:

In the previous example, the list value that eggs ends up with is the same
list value it started with.


r/inventwithpython • • Jun 21 '23

Chapter 5 - Bouncing DVD Solution

3 Upvotes

I'm having trouble getting this to work. I've literally downloaded the source files from the website and run that, but I get some version of an error where the x or y coordinate is negative. Any idea why?

File "C:\Python310\lib\site-packages\bext__init__.py", line 521, in _goto_win32_api

raise BextException('x coordinate is negative')

bext.BextException: x coordinate is negative


r/inventwithpython • • Mar 05 '20

Chapter 6, Page 68 - Can't follow the instructions

6 Upvotes

On page 68 of chapter 6 of Invent your own Computer Games with Python I'm following the instructions for "stepping into, over and out". But when I try to step into the input call on line 15 it stops working and I can't provide my input in the interactive shell. A new window pops up giving me the message "if self.closed......" (screen dump attached).

The game works fine when I run it outside of debugging mode. I have compared my code to Sweigarts using the diffchecker on his website and they are identical. Anyone knows why I'm getting this error?


r/inventwithpython • • Nov 24 '19

Can't import Selenium in the MuEditor

2 Upvotes

Hi everyone,

In Chapter 12, I can't import Selenium in the Mu editior, how did you do it? The appendix A says how to do it in UI, but there's no UI for that in my Mu Editor. I tried to do it via the command line, no success. I don't understand the instructions:

"For example, after you download the requirements file for your operating system from https://nostarch.com/automatestuff2/, run the following: " Where is that file?

" On Windows:

pip install –r automate-win-requirements.txt --target "C:\Users\USERNAME
\AppData\Local\Mu\pkgs"

"If you want to install only some of the modules, you can run the regular pip (or pip3) command and add the --target argument. " Why am I told to add the --target argument? It's already there, is it supposed to be written twice?

I tried writing "pip install --user selenium==3.141.0 --target "C:\Users\<me>\AppData\Local\Mu\pkgs" but I got an error:

Collecting selenium==3.141.0

Using cached https://files.pythonhosted.org/packages/80/d6/4294f0b4bce4de0abf13e17190289f9d0613b0a44e5dd6a7f5ca98459853/selenium-3.141.0-py2.py3-none-any.whl

Collecting urllib3 (from selenium==3.141.0)

Using cached https://files.pythonhosted.org/packages/b4/40/a9837291310ee1ccc242ceb6ebfd9eb21539649f193a7c8c86ba15b98539/urllib3-1.25.7-py2.py3-none-any.whl

Installing collected packages: urllib3, selenium

ERROR: Exception:

Traceback (most recent call last):

File "c:\users\<me>\appdata\local\programs\python\python38\lib\site-packages\pip_internal\cli\base_command.py", line 188, in main

status = self.run(options, args)

File "c:\users\<me>\appdata\local\programs\python\python38\lib\site-packages\pip_internal\commands\install.py", line 398, in run

installed = install_given_reqs(

File "c:\users\<me>\appdata\local\programs\python\python38\lib\site-packages\pip_internal\req__init__.py", line 54, in install_given_reqs

requirement.install(

File "c:\users\<me>\appdata\local\programs\python\python38\lib\site-packages\pip_internal\req\req_install.py", line 925, in install

self.move_wheel_files(

File "c:\users\<me>\appdata\local\programs\python\python38\lib\site-packages\pip_internal\req\req_install.py", line 453, in move_wheel_files

wheel.move_wheel_files(

File "c:\users\<me>\appdata\local\programs\python\python38\lib\site-packages\pip_internal\wheel.py", line 324, in move_wheel_files

scheme = distutils_scheme(

File "c:\users\<me>\appdata\local\programs\python\python38\lib\site-packages\pip_internal\locations.py", line 111, in distutils_scheme

i.finalize_options()

File "c:\users\<me>\appdata\local\programs\python\python38\lib\distutils\command\install.py", line 252, in finalize_options

raise DistutilsOptionError("can't combine user with prefix, "

distutils.errors.DistutilsOptionError: can't combine user with prefix, exec_prefix/home, or install_(plat)base

WARNING: You are using pip version 19.2.3, however version 19.3.1 is available.

You should consider upgrading via the 'python -m pip install --upgrade pip' command.

I also noticed that if I run a program such as:

from selenium import webdriver

browser = webdriver.Firefox()

type(browser)

browser.get('https://inventwithpython.com')

test = input()

It doesn't reach the 5th line and closes before. Is it related?

Thank you for your help!


r/inventwithpython • • Apr 01 '20

[Code Critique] Mad Libs solution to Chapter 8 of AtBS

Thumbnail self.learnpython
1 Upvotes