r/inventwithpython • u/ComfyOne • Nov 22 '19
ATBS 2nd Edition Release
Have there been any updates about when the new edition will be released? Last thing I saw was Nov 12 and I can't seem to find any other information.
r/inventwithpython • u/ComfyOne • Nov 22 '19
Have there been any updates about when the new edition will be released? Last thing I saw was Nov 12 and I can't seem to find any other information.
r/inventwithpython • u/tertra • Oct 30 '19
Does anyone know of a european resaler for the upcoming second edition?
I had a look at nostarch but the shipping is more than the book and this is without the expected import taxes.
r/inventwithpython • u/Roaches_in_train • Apr 24 '19
Hello,
For lots of reasons I don't like Udemy (
does not work on Mozilla and Opera, only in bloody safari
the progression bar takes lots of time to disappear when pausing and reproducing code and does not disappear at all on chrome. Makes it quite impossible to type along.

often going back to the start of the video if you pause, it drives you crazy to hear "Welcome to lesson..." dozens of times in a row or if you unfortunately have to pause or resize the window!!
and my screen went all black once when I maximized the window!!! ).
If I send a proof of purchase of the course, is it possible to have a link to the private videos on youtube instead? Now I have to download all the videos which I find really annoying.
r/inventwithpython • u/rkj2175 • Sep 14 '17
I have a problem with the Hangman game. The code that I copied from the textbook does not match the code that I compared it with, from the Diff Tool. I'm not talking about typing errors. There are a lot of differences in lines, spacing, and characters.
r/inventwithpython • u/Zeldacode • Aug 09 '17
Help me please. I'm new to coding and have been at this for hours. Syntax error near the bottom at gameIsDone
r/inventwithpython • u/[deleted] • Mar 12 '17
I have the correct version and architecture of Pygame on my computer. My question is how do I install it in so that I can just use PIP Install?
r/inventwithpython • u/Sesori • Feb 15 '16
Let me clarify my question a little more...
I was originally learning Python LPTHW, the author was strongly against using Python 3. However, after doing more research, it appears that the community agrees that LPTHW is outdated, and it is better for beginners to start learning Python 3 (or... the future).
I came upon this book, Automate Boring Stuff With Python. Thought that it might help me learn the ropes. The book came with one disclaimer in the introduction, "The coding style sometimes goes against best practices ... Sophisticated programming concepts—like object-oriented programming, list comprehensions, and generators—aren’t covered... this book is mostly concerned with getting programs to work with the least amount of effort."
I'm afraid that not learning best practices from the start would be bad for me down the road.
Thanks in advance for your advice.
r/inventwithpython • u/[deleted] • Feb 10 '16
It was quite challenging for me to do this one; I still feel quite lost with nested loops. Eventually I could do it as follows, but I think it's too much code.
tableData = [['apples', 'oranges', 'cherries', 'banana'],
['Alice', 'Bob', 'Carol', 'David'],
['dogs', 'cats', 'moose', 'goose']]
def printTable():
colWidths = [0] * len(tableData)
x = 0
y = 0
z = 0
for c in tableData:
for w in tableData[0]:
if len(w) > x:
x = len(w)
colWidths[0] = x
for w in tableData[1]:
if len(w) > y:
y = len(w)
colWidths[1] = y
for w in tableData[2]:
if len(w) > z:
z = len(w)
colWidths[2] = z
colWidths.sort()
maxWidth = colWidths[-1]
column = []
c = 0
for i in range(len(tableData[0])):
for j in range(len(tableData)):
column.append(tableData[j][i])
for i in tableData[0]:
for j in tableData:
print(column[c].rjust(maxWidth), end='')
c += 1
print()
printTable()It works, but I'm sure it should be much shorter. What am I not getting?
r/inventwithpython • u/planetbearth • Oct 11 '15
I've been reading and working through "Invent Your Own Computer Games with Python", and I find it to be amazing. I'm a beginner programmer and have worked my way through codecademy's Python and Javascript tracks, and this book, has been exactly what I need as a next step. I feel it gives a window into what actual programs might look like. Yes, I know these are supposedly beginner programs, but hey, you have to start somewhere.
I'm currently on Chapter 10, the Tic Tac Toe game, and I'm wondering what is the best way to learn from this book.
So far I've done a mixture of two things. First I've written down the code as the book suggest, and followed the step by step explanations of the various parts of the program. And If I don't understand something in the code, I'll try to figure it out by messing around with the concept in IDLE.
Secondly, when I've internalized the new concepts I'll try to implement my own version of game/code. So, more precisely, I don't know which way is better. Should I master the way the code is written in the book, knowing this has been written by a master of the trade, to the point where if I tried, without reference to the book, to recreate one of the games, my code would look quite similar to that of the book? Or should I make my own version of the game, and if this implementation works in the end, if they behave in the same manner, if the end user or the player of my game experiences the same thing as the book's game, can I be satisfied and move on? Or will this lead to bad programming practices, that in more complex programs will end up screwing me over?
Guaranteed if someone reviewed my code there would be red marks all over the place. So I dunno, what do you think?
r/inventwithpython • u/KashiGG • Jun 16 '15
*Edit: I forgot to mention that this is for "Automate the Boring Stuff with Python"
I've been attempting to figure this out for a few days now and I can't figure it out. I'm not looking for the answer, but if someone could point me in the right direction, I'd really appreciate it. The problem is the following:
Write a function named collatz() that has one parameter named number. If number is even, then collatz() should print number // 2 and return this value. If number is odd, then collatz() should print and return 3 * number + 1. Then write a program that lets the user type in an integer and that keeps calling collatz() on that number until the function returns the value 1. (Amazingly enough, this sequence actually works for any integer—sooner or later, using this sequence, you’ll arrive at 1! Even mathematicians aren’t sure why. Your program is exploring what’s called the Collatz sequence, sometimes called “the simplest impossible math problem.”) Remember to convert the return value from input() to an integer with the int() function; otherwise, it will be a string value. Hint: An integer number is even if number % 2 == 0, and it’s odd if number % 2 == 1. The output of this program could look something like this: Enter number: 3 10 5 16 8 4 2 1"
My code is the following:
Which gets me 3, 10, and then 5 repeating.
I've also tried: http://pastebin.com/gnsxyp8x
Which gets me 3, and then 10, 5 repeating.
Thanks to anyone who can help!
r/inventwithpython • u/Cardzilla • May 06 '15
Hey Guys, can you help me check my code? It's for the Table Printer Practice Project at the end of Chapter 6
tableData = [['apples', 'oranges', 'cherries', 'banana'],
['Alice', 'Bob', 'Carol', 'David'],
['dogs', 'cats', 'moose', 'goose']]
def printTable(tableData):
colWidths = [0] * len(tableData)
for i in tableData:
for j in i:
for k in range(len(tableData)):
if len(j) > colWidths[k]:
colWidths[k] = len(j)
colWidths.sort()
print(colWidths[-1])
for a in range(len(tableData)-2):
for b in range(len(tableData[0])):
print(tableData[a][b].rjust(colWidths[-1])+tableData[a+1][b].rjust(colWidths[-1])+tableData[a+2][b].rjust(colWidths[-1]))
printTable(tableData)the code produces the right ouput, but I had to put a -2 in the for a in range(len(tableData)-2): line and I have no idea why that works.
Thanks and let me know if there's a more elegant solution.
r/inventwithpython • u/MasterOfProgramming • Feb 24 '15
This isn't really a question, but in Ch. 18 Collision Detection, I noticed something that would be really slow with the collision detection. The worst case scenario would be that it searches through every single pixel in one rectangle before it detects overlapping between them.
The much better way to do collision would be something like Separating Axis Theorem. Which ever rectangles' right X is furthest to the right, take it and average it with the left X of the other point, and the same for top and bottom Y. Check only the point of the coordinated found. If that point is inside either rectangle, they overlap.
r/inventwithpython • u/elgeorgemx • Nov 11 '14
Just wanted to say that i´m working with the "Invent Your Own Computer Games with Python" book, and i´m learning a lot. My goal is to make my children to get interested in programming, and this book is just what i was looking for. Thanks a lot!!! By the way, i´m also new to Reddit, and feel so lucky about finding this learning community.
r/inventwithpython • u/peileppe • May 19 '14
Last week, I was wondering how to convert a text-mode version of my game "squadron4" in graphics mode -- see http://redd.it/25pzrb and was informed about "pygcurse", made the transition this week-end and it worked - see the result at https://code.google.com/p/squadron4g/
r/inventwithpython • u/AlSweigart • May 24 '26
r/inventwithpython • u/Affectionate-Bad9435 • Jan 16 '26
In the book "Automate the Boring Stuff with Python, 3rd Ed" there is an instruction to install pytesseract On Linux: pip3 install pytesseract==0.3.10
This does not work in latest release of Linux Mint, or may be obsolete. What is the correct one?
r/inventwithpython • u/voltz-n-boltz • Jan 05 '26
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 • u/AlSweigart • Sep 29 '25
r/inventwithpython • u/lapislapislapis • Jun 11 '24
hello everyone, i have a problem with my code. In chapter 5, its explained how to do a game called dragon realm. I wrote the code and when i tried to run it, but no text showed up. I tried copypasting the code and running it but it didnt work either. I dont know if im supposed to do something and i need help. i'm using python 3.12.4.

please help me, ive did all the other games introduced before this one and something like this never happened.
r/inventwithpython • u/novacarbon • May 05 '23
I'm doing projects in Automate the boring stuff. This particular project asks me to Write a program to find out how often a streak of six heads or a streak of six tails comes up in a randomly generated list of heads and tails.
The #comments are hint by the author. This program I created ran just fine but the chance of streak is surprisingly high to me: ~152% - 153%. So I'm wondering if I got the logic right? Any help will be greatly appreciated. Thank you
import random
def flip():
random_num = random.randint(0, 1)
if random_num == 1:
return "H"
else:
return 'T'
numberOfStreaks = 0 #author wrote this line
for experimentNumber in range(10000): #author wrote this line
# Code that creates a list of 100 'heads' or 'tails' values.
head_tail_str = ""
side = flip()
head_tail_str += side
for _ in range(99):
prev_side = side
side = flip()
if side != prev_side:
head_tail_str += f",{side}"
else:
head_tail_str += side
# Code that checks if there is a streak of 6 heads or tails in a row.
head_tail_lst = head_tail_str.split(',')
for item in head_tail_lst:
if len(item) >= 6:
numberOfStreaks += (int(len(item)) // 6)
print('Chance of streak: %s%%' % (numberOfStreaks / 100)) #author wrote this linep/s: I've been learning Python for 1 month
r/inventwithpython • u/jpgoldberg • Apr 16 '22
I'm not certain whether this is the place to discuss or ask about Real-World Python. It is an InventWithPython book but isn't by Al Sweigart. I am asking here anyway, and hope to be (politely) directed elsewhere if this isn't the right place.
My question is an advanced statistical modeling question that goes beyond the project as specified. But this is the first time I've done a Monte Carlo simulation, and I've sort of become obsessed with fine tuning the project.
When doing the Monte Carlo simulation, it was fine to get a histogram of number of days it took to find the the sailor, but I wanted to also calculate the likelihood that the sailor is found alive. In my first version, I just used found alive if found in 3 days, dead otherwise. But I don't feel that that captured the urgency of trying to find them sooner and that three days is kind of iffy.
My intuition is that probability of dying on any given day should follow a Gamma distribution, but I have nothing to back up that intuition. And it certainly doesn't give me the parameters for the Gamma distribution. So I just played around by drawing curves of the cumulative distribution function and settled on a = 6, and scale = 1/2.
import scipy.stats as stats
def prob_alive_on_day(day):
alpha = 6
beta = 2
p_dead = stats.gamma.cdf(day, a=alpha, scale = 1/beta)
return 1 - p_dead(I should also say that this is rather grim compared to the alive if found within three days. Even with using a strategy based on the Probability of Discovery extra, the sailor is only found alive about 75% of the time.)
Anyway, as morbid as this whole thing is, I am wondering if there is data or theory to help model this right.
r/inventwithpython • u/tom_thumb_1 • Nov 29 '21
I'm enjoying my first taste of python (and programming), using Automate the Boring Stuff. Ch3 has practice projects, relating to Collatz sequence. I'm not sure where to find or ask for help to compare my code with someone else's. My code appears to work, but it would be interesting to see different approaches. Anyone care to comment or point me in right direction, thanks.
For anyone interested, here's my code, firstly without the "try, except" and then with...
-------------------------------------------------------------------
# Ask for an integer
print('please enter an integer')
entry = int(input())
# Define collatz function
def collatz(number):
if number % 2 == 0:
print(number // 2)
return number // 2
elif number % 2 == 1:
print(3*number + 1)
return 3*number + 1
# Main code loop
while entry != 1:
entry = collatz(entry)
print('Converged to 1')---------------------------------------------------------------
# Define collatz function
def collatz(number):
if number % 2 == 0:
print(number // 2)
return number // 2
elif number % 2 == 1:
print(3 * number + 1)
return 3*number + 1
# Ask for an integer
print('please enter an integer')
# Main code loop
loop = True
while loop:
try:
entry = int(input())
except ValueError:
print('That is not an integer, please try again')
continue
while entry != 1:
entry = collatz(entry)
Loop = False
print('Converged to 1')r/inventwithpython • u/Apprehensive_Peak549 • Oct 08 '21
Craps is a unique casino game played with 2 dice that is often shown in movies. You will create a program that simulates a game of craps based on the following rules of the game:
On the first roll:- if you roll a 7 or 11, you win!- if you roll a 2 or 12, you lose - if you roll a 3,4,5,6,8,9 or 10 you rolled "point" and you must roll again
On subsequent rolls (any roll after the first roll)- if you roll your point, you win!- if you roll 7 or 11, you lose- if you roll anything else, this becomes your new point and you must roll again
Your user output will indicate what the user rolls throughout the game as it is played, in addition to win/lose/play again messages.
r/inventwithpython • u/Teslas_Understudy • Oct 05 '21
Will there be a way to purchase through inventwithpython.com instead of https://www.amazon.ca/gp/product/B09BKL34VL/ref=dbs_a_def_rwt_bibl_vppi_i6 ?
I love the "bonuses" that come with preordering from inventwithpython.com
TIA.
r/inventwithpython • u/Sensitive-Citron-981 • Mar 28 '21
Hello! I have questions. I began write code tkinter app in pycharm. But I don't know how to continuing.
I have a doc file on how to create an application and a python file with code I wrote. Will confidentiality be maintained if I place(or paste) it here?