r/inventwithpython • • Jan 18 '14

problems with K_SPACE

1 Upvotes

I seem to be having problems with K_SPACE I tried making searching for the event a def just to trouble shoot but it only worked for QUIT. Can anyone tell me why I am not see a print when I hit the space bar

import pygame, sys from pygame.locals import *

pygame.init() DISPLAYSURF = pygame.display.set_mode((400,300)) pygame.display.set_caption('Hello World!')

WHITE = (255, 255, 255) GREEN = (0, 255, 0) BLUE = (0, 0, 128)

fontObj = pygame.font.Font('freesansbold.ttf', 32) textSurfaceObj = fontObj.render ('Hello World!', True, GREEN, BLUE) textRectObj = textSurfaceObj.get_rect() textRectObj.center = (200, 150)

def main(): while True: # main game loop DISPLAYSURF.fill(WHITE) # draw the window DISPLAYSURF.blit(textSurfaceObj,textRectObj) checkForQuit() checkForSpaceBar() pygame.display.update()

def checkForQuit(): for event in pygame.event.get(): if event.type == QUIT: pygame.quit() sys.exit()

def checkForSpaceBar(): for event in pygame.event.get(): if event.type == K_SPACE and KEYDOWN: print event.key

if name == 'main': main()


r/inventwithpython • • Mar 27 '17

[invent] Chapter 3, need help with the "Guess The Number" game.

1 Upvotes

Windows 7 64 bit with Python 3.5.2, need help. https://pastebin.com/DkCpFZzN Code is right there. I'm trying to get the "random" function working but after line 5 where I enter my name, the error says "line 8, in <module> number = random.randit(1, 20) AttributeError: module 'random' has no attribute 'randit'"


r/inventwithpython • • Aug 29 '15

Problem with Reversi (Invent Games w/Python chap. 15)

1 Upvotes

Hi everyone, I'm having an issue with the code in chapter 15 of Invent Games with Python. I've entered the code for Reversi, but I keep on getting an error that seems to boil down to this line:

for xdirection, ydirection in [[0, 1], [1, 1], [1, 0], [1. -1], [0, -1], [-1, -1], [-1, 0], [-1, 1]]:

And the error I'm getting is:

ValueError: need more than 1 value to unpack

Any ideas?


r/inventwithpython • • Jan 09 '18

addressing list element error

1 Upvotes

There is a strange error when I try to change an element in a simple empty list Board1 size 3x3 (all the elements are ' '). For example Board1[0][1]='12' changes 3 elements in the Board1 instead of only one, if the list is generated through a for loop, otherwise it is ok. I would appreciate if someone explains what is the problem here? Please see the code and the difference..

line=[' ']*3

Board1=[]

for y in range(3):

 Board1.append(line)

print('Board1=%s' %(Board1))

Board2=[[' ',' ',' '],[' ',' ',' '],[' ',' ',' ']] print('Board2=%s' %(Board2))

Board1[0][1]='12'
print('new Board1=%s' %(Board1))

Board2[0][1]='12'
print('new Board2=%s' %(Board2))


r/inventwithpython • • Sep 06 '15

Problem with Pyerclip

1 Upvotes

I feel very stupid but I cannot get pyperclip to work. I can import it but when I try to use it I get this error. What am I doing wrong?

Traceback (most recent call last):

File "<ipython-input-18-dcb46002907e>", line 1, in <module> pyperclip.paste()

File "D:\Downloads\pyperclip-1.5.11\pyperclip_init_.py", line 34, in _pasteWindows d.user32.OpenClipboard(0 if PY2 else None)

ArgumentError: argument 1: <class 'TypeError'>: wrong type


r/inventwithpython • • Dec 11 '14

A question about the book

2 Upvotes

So, I just wanted to ask, what important python topics weren't covered in the "Invent your own computer games with python" book and where should I learn them?


r/inventwithpython • • Jan 25 '14

I got error: Unable to open file 'beeps.wav'

1 Upvotes

I am following instruction in Making Game about playing sound. I downloaded "beeps.wav" file and put it into my working directory. Then I run ipython and tried to play the sound:

import pygame from pygame.locals import *

soundObj = pygame.mixer.Sound('beeps.wav') soundObj.play()

Then I got output:

error Traceback (most recent call last) <ipython-input-7-370652564b32> in <module>() ----> 1 soundObj = pygame.mixer.Sound('beeps.wav')

error: Unable to open file 'beeps.wav'

Can you please advise what did I do wrong? Thanks


r/inventwithpython • • Apr 05 '16

Ch.3 Collatz Function

1 Upvotes

I am having a little trouble with global variables. What I am trying to do is let the user know the number of operations performed before the number 1 was achieved. Is it possible to pull out a local variable of n to the global space, and if so how?

print("This is console module")
def collatz(number):
    global n
    while number != 1:
        if number%2 == 0:
            number = number//2
            n = n+1
        else: 
            number = 3*number+1
            n = n+1
print('Input a number')
number = int(input())
print('It took ' + str(n) + ' operations to achieve your number = 1')

r/inventwithpython • • Oct 07 '16

Openpyxl - Writing to Empty/New Spreadsheet (automate the boring stuff w/ python)

2 Upvotes

I'm having problems with writing to an empty excel sheet. I use the cell method to write something to the cells but I can get an error: 'function' object has no attribute 'cell. I sort of understand based on this error but I just don't understand how to write to the cells without the cell method. Any ideas/help would be greatly appreciated.


r/inventwithpython • • Mar 18 '17

[invent] I am trying to make a game merging the animation with the collier game? I can't seem to get the enemy object to move.

1 Upvotes

I can't seem to get the trump rectangle to move. I think it is because the object on screen is both a image and a rect. not just a rect. Look under Trump AI section http://pastebin.com/gwUjTF9H


r/inventwithpython • • Jan 09 '18

Automate the boring stuff: chapter 4 problem

4 Upvotes

The question can be found here, at the bottom of the page: http://automatetheboringstuff.com/chapter4/

I reached the following result, which works fine (numbers added to identify lines of code):

1. for y in range(len(grid[0])):	
2.     for x in range(len(grid)):
3.         if x < len(grid)-1:				
4.             print(grid[x][y], end="")
5.         else:
6.             print(grid[x][y], end="\n")

However, this is more elegant:

7. for x in range(len(grid[0])):
8.     for y in range(len(grid)):
9.         print(grid[y][x],end='')
10.    print()

To be honest, I'm having trouble visualizing what the code is doing in the second, shorter example. I don't see how it's able to rotate the grid correctly. If someone could maybe walk me through what exactly is happening on a step by step basis, it might help it click for me.


Okay, as I was writing this, I started thinking about my code, and it I think it clicked for me. Below is my understanding of the discrete sequence of operations that is happening with this code:

x and y start at 0. For x=0, we must run the for-loop at line 8. That loops will run 9 times (because len(grid) is 9) before we run the for-loop at line 7 again. The result is that we print the 0th element of sublist 0, then the 0th element of sublist 1, and so forth. Working from printing [0][0] to printing [9][0].

At [9][0], we complete the line 8 for-loop and drop down to line 10, where print() gives us our linebreak.

Then we repeat the process, only instead of x=0, x=1. So we do the for-loop at 8 again, which requires us to print grid[0][1] though [9][1] before print() runs and the line 7 for loop repeats .

This continues until we have completed all 6 iterations of the x for-loop.


Is this a correct understanding of the more elegant code, or have I missed something?


r/inventwithpython • • Sep 11 '15

Counting Google Search Results

3 Upvotes

I was trying to apply the content of Ch. 11 of "Automate..." and I am facing a freaky issue... My task is to search Google for news on a topic in a certain date range and count the number of results.

my simple code is

payload = {'as_epq': 'James Clark', 'tbs':'cdr:1,cd_min:1/01/2015,cd_max:1/01/2015','tbm':'nws'}

r = requests.get("https://www.google.com/search", params=payload)

soup = bs4.BeautifulSoup(r.text)

elems = soup.select('#resultStats')
print(elems[0].getText())

And the result I get is

About 8,600 results

So apparently all works... apart from the fact that the result is wrong. If I open the URL in Firefox (I can obtain the complete URL with r.url)

https://www.google.com/search?tbm=nws&as_epq=James+Clark&tbs=cdr%3A1%2Ccd_min%3A1%2F01%2F2015%2Ccd_max%3A1%2F01%2F2015

I see that the results are actually only 2, and if I manually download the HTML file, open the page source and search for id="resultStats" I find that the number of results is indeed 2!

Can anybody help me to understand why searching for the same id tag in the saved HTML file and in the soup item lead to two different numerical results?


UPDATE It seems that the problem is the custom date range that does not get processed correctly by requests.get. If I use the same URL with selenium I get the correct answer

from selenium import webdriver
driver = webdriver.Firefox()
driver.get(url)
content = driver.page_source
soup = bs4.BeautifulSoup(content)
elems = soup.select('#resultStats')
print(elems[0].getText())

And the answer is

2 results (0.09 seconds) 

The problem is that this methodology seems to be more cumbersome because I need to open the page in Firefox...


r/inventwithpython • • Aug 19 '17

Character count

3 Upvotes

I was looking at the character count in chapter 5, here's the code:

message = "It was a bright cold day etc"
count = {}

for character in message:
    count.setdefault(character, 0)
    count[character] = count[character] + 1

print(count)

It works, but how does python know what "character" is? The program doesn't define it, so is the meaning built in to python itself?


r/inventwithpython • • Mar 15 '17

[Invent] Collier Game

2 Upvotes

What is a easy way I can make a scoreboard for this game?


r/inventwithpython • • Dec 20 '14

Just finished chapter 3. Made a few changes with what I learned. Is there a better way to do this?

3 Upvotes

So once I finished up chapter 3 I wanted to experiment a little to see how well I understood the material. I added an option for the user to say how many guesses they wanted and a count down of those guesses.

#guess numbers
import random

guessesTaken = 0

print ('Hey what is your name?')
myName = input()

number = random.randint(1, 200)
print ('Well, ' + myName + ', I am thinking of a number between 1 and 200. How many guesses do you need?')
guessesWantedInt = int(input())
while guessesTaken < guessesWantedInt:
    guessesWanted = guessesWantedInt - guessesTaken
    guessesLeft = str(guessesWanted)
    if guessesWanted > 1:
        print ('Take a guess. You have ' + guessesLeft + ' guesses left.' )
    else:
        print ('Take a guess. You have ' + guessesLeft + ' guess left.' )
        
    
    guess = input()
    guess = int(guess)

    guessesTaken = guessesTaken + 1

    if guess < number:
        print ('Your guess is too low.')
    if guess > number:
        print ('Your guess is too high.')
    if guess == number:
        break

if guess == number:
    guessesTaken = str(guessesTaken)
    print ('Good job ' + myName + '! You did guessed it in only '+ guessesTaken + ' guesses!')

if guess != number:
    number = str(number)
    print ('You are out of guesses. The number I was thinking of was ' + number)

I would really like pointers on how to make this cleaner if possible. I guess I will learn more as i go through the book too. Just thought I'd share a little bit as I go along.


r/inventwithpython • • Mar 18 '17

[automate]Chapter 3 Practice Project Collatz

1 Upvotes

I can't figure out why the output is just one loop. http://pastebin.com/LZyNiDeq


r/inventwithpython • • Apr 01 '21

"Automate the Boring Stuff with Python" online course is free to sign up for the next few days with code APR2021FREE

47 Upvotes

https://inventwithpython.com/automateudemy (This link will automatically redirect you to the latest discount code.)

You can also click this link or manually enter the code: APR2021FREE

https://www.udemy.com/course/automate/?couponCode=APR2021FREE

This promo code works until the 4th (I can't extend it past that). Sometimes it takes an hour or so for the code to become active just after I create it, so if it doesn't work, go ahead and try again a while later. I'll change it to APR2021FREE2 in three days.

Udemy has changed their coupon policies, and I'm now only allowed to make 3 coupon codes each month with several restrictions. Hence why each code only lasts 3 days. I won't be able to make codes after this period, but I will be making free codes next month. Meanwhile, the first 15 of the course's 50 videos are free on YouTube.

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 2nd edition of Automate the Boring Stuff with Python is free online: https://automatetheboringstuff.com/2e/

  • I do plan on updating the Udemy course for the second edition, but it'll take a while because I have other book projects I'm working on. Expect that update to happen in mid-2021. 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.

  • It's totally fine to start on the first edition and then read the second edition later. I'll be writing a blog post to guide first edition readers to the parts of the second edition they should read.

  • I wrote a blog post to cover what's new in the second edition

  • You're not too old to learn to code. You don't need to be "good at math" to be good at coding.

  • Signing up is the first step. Actually finishing the course is the next. :) There are several ways to get/stay motivated. I suggest getting a "gym buddy" to learn with. Check out /r/ProgrammingBuddies


r/inventwithpython • • Mar 27 '21

Russian substituten cipher code- python trouble reading.

3 Upvotes

Hello,

I am trying to adapt the simple substitution hacker code from the 'Cracking Codes with Python'book to a russian cipher. What I did so far:

-Changed the LETTERS to russian (lower key; like the cipher I am trying to crack).

-I also have a russian word library called dictionary.txt

-Generated the wordpattern file for that dictionary.

-Made sure all files have on top: # -*- coding: utf-8 -*- (found this on http://blog.rolffredheim.com/2013/11/top-seven-tips-for-processing-foreign.html)

Hereby the full code of the main file simpleSubHacker.py:

message that needs decription has been snipped.

However the result I get from running this script in IDLE shell 3.9.2 is an empty mapping and a 'hacked message showing only spaces and 't'.
It seems like python can't 'read' the russian letters. Anybody any suggestions on how to fix this?

Mapping:

{'а': [], 'б': [], 'в': [], 'г': [], 'д': [], 'е': [], 'ё': [], 'ж': [], 'з': [], 'и': [], 'й': [], 'к': [], 'л': [], 'м': [], 'н': [], 'о': [], 'п': [], 'р': [], 'с': [], 't': [], 'у': [], 'ф': [], 'х': [], 'ц': [], 'ч': [], 'ш': [], 'щ': [], 'ъ': [], 'ы': [], 'ь': [], 'э': [], 'ю': [], 'я': []}

Copying hacked message to clipboard:

____________________ _______________ _______ т_________ ____т___ _________________________

The code:

# Simple Substitution Cipher Hacker

# https://www.nostarch.com/crackingcodes (BSD Licensed)

import re, copy, pyperclip, simpleSubCipher, wordPatterns, makeWordPatterns

# -*- coding: utf-8 -*-

LETTERS ='абвгдеёжзийклмнопрсtуфхцчшщъыьэюя'

nonLettersOrSpacePattern = re.compile('[ЁёА-я]')

def main():

message = 'абвбглеёжзийжакажлжз мзйгноджпгниждл бедрсжс тилбвкзохз бсжотсие внзйорджредвилбцбгшбеманц'

# Determine the possible valid ciphertext translations:

print('Hacking...')

letterMapping = hackSimpleSub(message)

# Display the results to the user:

print('Mapping:')

print(letterMapping)

print()

print('Original ciphertext:')

print(message)

print()

print('Copying hacked message to clipboard:')

hackedMessage = decryptWithCipherletterMapping(message, letterMapping)

pyperclip.copy(hackedMessage)

print(hackedMessage)

def getBlankCipherletterMapping():

# Returns a dictionary value that is a blank cipherletter mapping.

return {'а': [], 'б': [], 'в': [], 'г': [], 'д': [], 'е': [], 'ё': [],

'ж': [], 'з': [], 'и': [], 'й': [], 'к': [], 'л': [], 'м': [],

'н': [], 'о': [], 'п': [], 'р': [], 'с': [], 't': [], 'у': [],

'ф': [], 'х': [], 'ц': [], 'ч': [], 'ш': [], 'щ': [], 'ъ': [],

'ы': [], 'ь': [], 'э': [], 'ю': [], 'я': []}

def addLettersToMapping(letterMapping, cipherword, candidate):

# The \letterMapping` parameter is a "cipherletter mapping" dictionary`

# value that the return value of this function starts as a copy of.

# The \cipherword` parameter is a string value of the ciphertext word.`

# The \candidate` parameter is a possible Russian word that the`

# cipherword could decrypt to.

# This function adds the letters of the candidate as potential

# decryption letters for the cipherletters in the cipherletter

# mapping.

for i in range(len(cipherword)):

if candidate[i] not in letterMapping[cipherword[i]]:

letterMapping[cipherword[i]].append(candidate[i])

def intersectMappings(mapA, mapB):

# To intersect two maps, create a blank map, and then add only the

# potential decryption letters if they exist in BOTH maps.

intersectedMapping = getBlankCipherletterMapping()

for letter in LETTERS:

# An empty list means "any letter is possible". In this case just

# copy the other map entirely.

if mapA[letter] == []:

intersectedMapping[letter] = copy.deepcopy(mapB[letter])

elif mapB[letter] == []:

intersectedMapping[letter] = copy.deepcopy(mapA[letter])

else:

# If a letter in mapA[letter] exists in mapB[letter], add

# that letter to intersectedMapping[letter].

for mappedLetter in mapA[letter]:

if mappedLetter in mapB[letter]:

intersectedMapping[letter].append(mappedLetter)

return intersectedMapping

def removeSolvedLettersFromMapping(letterMapping):

# Cipherletters in the mapping that map to only one letter are

# "solved" and can be removed from the other letters.

# For example, if 'A' maps to potential letters ['M', 'N'], and 'B'

# maps to ['N'], then we know that 'B' must map to 'N', so we can

# remove 'N' from the list of what 'A' could map to. So 'A' then maps

# to ['M']. Note that now that 'A' maps to only one letter, we can

# remove 'M' from the list of letters for every other

# letter. (This is why there is a loop that keeps reducing the map.)

loopAgain = True

while loopAgain:

# First assume that we will not loop again:

loopAgain = False

# \solvedLetters` will be a list of uppercase letters that have one`

# and only one possible mapping in \letterMapping`:`

solvedLetters = []

for cipherletter in LETTERS:

if len(letterMapping[cipherletter]) == 1:

solvedLetters.append(letterMapping[cipherletter][0])

# If a letter is solved, than it cannot possibly be a potential

# decryption letter for a different ciphertext letter, so we

# should remove it from those other lists:

for cipherletter in LETTERS:

for s in solvedLetters:

if len(letterMapping[cipherletter]) != 1 and s in letterMapping[cipherletter]:

letterMapping[cipherletter].remove(s)

if len(letterMapping[cipherletter]) == 1:

# A new letter is now solved, so loop again.

loopAgain = True

return letterMapping

def hackSimpleSub(message):

intersectedMap = getBlankCipherletterMapping()

cipherwordList = nonLettersOrSpacePattern.sub('', message.upper()).split()

for cipherword in cipherwordList:

# Get a new cipherletter mapping for each ciphertext word:

candidateMap = getBlankCipherletterMapping()

wordPattern = makeWordPatterns.getWordPattern(cipherword)

if wordPattern not in wordPatterns.allPatterns:

continue # This word was not in our dictionary, so continue.

# Add the letters of each candidate to the mapping:

for candidate in wordPatterns.allPatterns[wordPattern]:

addLettersToMapping(candidateMap, cipherword, candidate)

# Intersect the new mapping with the existing intersected mapping:

intersectedMap = intersectMappings(intersectedMap, candidateMap)

# Remove any solved letters from the other lists:

return removeSolvedLettersFromMapping(intersectedMap)

def decryptWithCipherletterMapping(ciphertext, letterMapping):

# Return a string of the ciphertext decrypted with the letter mapping,

# with any ambiguous decrypted letters replaced with an _ underscore.

# First create a simple sub key from the letterMapping mapping:

key = ['x'] * len(LETTERS)

for cipherletter in LETTERS:

if len(letterMapping[cipherletter]) == 1:

# If there's only one letter, add it to the key.

keyIndex = LETTERS.find(letterMapping[cipherletter][0])

key[keyIndex] = cipherletter

else:

ciphertext = ciphertext.replace(cipherletter.lower(), '_')

ciphertext = ciphertext.replace(cipherletter.upper(), '_')

key = ''.join(key)

# With the key we've created, decrypt the ciphertext:

return simpleSubCipher.decryptMessage(key, ciphertext)

if __name__ == '__main__':

main()


r/inventwithpython • • Mar 28 '21

have to write multiwindows and multifunctions tkinter app

4 Upvotes

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?


r/inventwithpython • • Mar 21 '21

Calm Programming - Blackjack (a casual, no-commentary video series)

Thumbnail
youtube.com
22 Upvotes

r/inventwithpython • • Mar 22 '21

Calm Programming - Conway's Game of Life

Thumbnail
youtube.com
21 Upvotes

r/inventwithpython • • Jul 07 '15

Automate the Boring Stuff Chapter 7 Practice Project - How to Use a Variable in Creating a Regex Pattern Object

1 Upvotes

I've been going through all the practice projects and have been loving all of them so far, but I've stumbled into a little roadblock. I was able to replicate the basic strip() string method to remove all whitespace characters at the beginning or end of the string. However, I am currently unable to create a Regex pattern object that uses an argument as part of the string. Many of my previous attempts have resulted in a SyntaxError: invalid syntax. I've tried Googling and searching on StackOverflow, but to no avail.

Could someone please provide some guidance on how to solve this problem? If I need to provide additional information, please let me know because this is the first time I have asked a coding related question online. Thanks!

My Current Solution

def newStrip(text, removedChar = ' '):
    whitespaceRegex = re.compile(r'^\s+|\s+$)
    otherRegex = re.compile(^removedChar|removedChar) #how do I use variables
    if removedChar == ' ':
        print(whitespaceRegex.sub('', text))
    else:
        print(otherRegex.sub('', text))

Question for Reference

Write a function that takes a string and does the same thing as the strip() string method. If no other arguments are passed other than the string to strip, then whitespace characters will be removed from the beginning and end of the string. Otherwise, the characters specified in the second argument to the function will be removed from the string.


r/inventwithpython • • Feb 09 '16

Mad Lib Practice Project

2 Upvotes

I'm trying to practice using a regex to find all occurrences of a specifically formatted part of speech, and then replace those parts of speech with new user provide parts of speech.

The code is here.

The big problem I'm having is that I'm unable to get the program to effectively replace each new occurrence of the part of speech. I tried using the regex.sub() method, however, despite still using multiple inputs it only iterated the last input over the entire text.

And here's the text for the madlib that I grabbed off a random website:

Mad Libs!

A DAY AT THE ZOO!

Today I went to the zoo. I saw a ADJECTIVE NOUN jumping up and down in its tree. He VERB ADVERB through the large tunnel that led to its ADJECTIVE NOUN. I got some peanuts and passed them through the cage to a gigantic gray NOUN towering above my head. Feeding that animal made me hungry. I went to get a ADJECTIVE scoop of ice cream. It filled my stomach. Afterwards I had to VERB ADJECTIVE to catch our bus. When I got home I VERB my mom for a ADJECTIVE day at the zoo.


r/inventwithpython • • Dec 06 '17

[automate] Broken link about multithreaded programming

3 Upvotes

The first link below in "additional online resources" section at https://www.nostarch.com/automatestuff/ to the tutorial about multithreaded programming (also mentioned in Chapter 15 of "Automate ...") seems not to work ("404 Not Found error" when clicked on).

http://inventwithpython.com/blog/2013/04/22/multithreaded-python-tutorial-with-threadworms/

I found an alternative address through Google but it seems to be missing the pictures in the tutorial.

https://inventwithpython.com/blog/2013/04/22/multithreaded-python-tutorial-with-the-threadworms-demo/

Would anyone know if there is a better version available elsewhere? Thank you.


r/inventwithpython • • Nov 02 '13

Do something if Mouse clicked in certain area of screen?

1 Upvotes

I want my game to wait after playerroll() for another mouseclick, then if this mouseclick is in a specific area (ie over a certain image) then perform an action on that image. My code so far is below but it just carries on with the code without waiting to see if another mouseclick happened or if it was in that certain area. Can anyone help?

for event in pygame.event.get():
    if event.type == pygame.MOUSEBUTTONDOWN:
        dice_roll()
        playerroll()
    for event in pygame.event.get():
        if event.type == pygame.MOUSEBUTTONDOWN:
            if jackpot[roll1-1].get_rect().collidepoint(pos):
                moveletter(roll1-1)
                jackpot[roll1-1] = "none"