r/inventwithpython • • Dec 07 '24

Cracking Codes with Python: publicKeyCipher.py issue

1 Upvotes

I've used the online diff tool and even compared my code to that in the CrackingCodesFiles.zip archive, but I run into an error on decryption. I have narrowed it down to the calculation of charIndex on line 63 as the cupit. The calcualtion, as-is, works with the smaller example from a previous chapter, but stepping through, I get a very large integer for charIndex instead of a value between 0 and 65.

The program throws an IndexError on line 65 when attempting to insert the symbol into blockMessage using the very long charIndex value. I checked the errata and found nothing there with regard to this calculation. Any ideas on how to fix this mathematically in a way that won't break decryption in some other use-case?

I am running this script on RHEL 9.5 using Python 3.12. Below is the error I get when decrypting...

Reading from encrypted_file.txt and decrypting...
Traceback (most recent call last):
File "/lab/cracking_codes/publicKeyCipher.py", line 158, in <module>
main()
File "/lab/cracking_codes/publicKeyCipher.py", line 30, in main
decryptedText = readFromFileAndDecrypt(filename, privKeyFilename)
File "/lab/cracking_codes/publicKeyCipher.py", line 154, in readFromFileAndDecrypt
return decryptMessage(encryptedBlocks, messageLength, (n, d), blockSize)
File "/lab/cracking_codes/publicKeyCipher.py", line 91, in decryptMessage
return getTextFromBlocks(decryptedBlocks, messageLength, blockSize)
File "/lab/cracking_codes/publicKeyCipher.py", line 65, in getTextFromBlocks
blockMessage.insert(0, SYMBOLS[charIndex])
IndexError: cannot fit 'int' into an index-sized integer


r/inventwithpython • • Sep 24 '23

[HELP] HTTP2 protocol ERROR keeps happening inconsistently when scraping website with Selenium python

1 Upvotes

I'm going through Automate the boring stuff book and instead of downloading the comic images for the exercise project, I decided to try scraping Sotheby auction site. I've written a script that goes through all the pages on https://sealed.sothebys.com (that have listings of auctioned items), collecting all the items' url, then open each url and download the 1st image of each item.

There are 2 specific points in the execution where the HTTP2 protocol ERROR (this site is unsecure) bug could happen:

  1. When clicking the next button to go to the next page

  2. When opening each auction item's url in a loop

I've isolated just the code for those 2 parts for debugging

I. Clicking the Next Button:

from selenium import webdriver
import time

browser = webdriver.Chrome()
browser.get('https://sealed.sothebys.com')
time.sleep(5)
# click on Next button
n = 0
while True:
    next_button = browser.find_element('css selector', 'button.sc-dd495492-1:nth-child(5)')
    if not next_button.is_enabled():
        print('End of current item on auction catalogue.')
        break
    browser.execute_script("arguments[0].click()", next_button)
    n += 1
    print(n)
    time.sleep(2) 

When this works, it outputs in order: 1 2 'End of current item on auction catalogue.'

(there are only 3 listings pages at this moment)

When it doesn't work, it outputs: 1 <Error message

II. Opening auction items' urls:

I have to remove the https:// part and replace '.' in the url with '_' to avoid issues with posting

from selenium import webdriver
import time

new_items = ['sealed_sothebys_com/YF23/auction', 
         'google_com',
         'sealed_sothebys_com/BC23/auction', 
         'sealed_sothebys_com/michael-jordan/auction', 
         'google_com', 
         'sealed_sothebys_com/the-black-rose/auction', 
         ]

for url in new_items:
browser.get(url)
time.sleep(2)
try:
    item_name_ele = browser.find_element('tag name', 'h3')
except:
        print('Error')

60-70% of the time, the error starts happening with the 2nd url and every url afterwards, 30-39% of the time, the first few urls will have no problems (the number of the working urls varies, could be 3 ,5, 10, more than 10 ..) and only 1% of the time or less that 100% of the urls work. Once the error happens with 1 url, all the urls after it will have the error as well. I've inserted 2 google links in the list to test, and they still work fine even if the error happens with the sothebys url right before them.

WHAT I'VE TRIED

  1. I run the code with Firefox driver in the beginning. When the error happened, I thought to try the Chrome driver. It worked with 100% the urls the 1st time I run it with Chromedriver. But from the 2nd time onwards, the error starts showing up with no difference to using Firefox driver.

  2. I tried turning off my antivirus software. Didn't work.

  3. I tried browser.delete_all_cookies() then browser.refresh() when the code encounters error finding element on page. Didn't work. (I did this because if I manually do this on the page opened with selenium: delete cookies and refresh -> the error will disappear, but it will appear again when I click on any link on that page)

  4. I tried adding arguments for Chrome options

from selenium.webdriver.chrome.options import Options as ChromeOptions

options = ChromeOptions()
# cloud_options = {}

options.accept_insecure_certs = True
options.add_argument('--ignore-ssl-errors=yes')
options.add_argument('--ignore-certificate-errors')
options.add_argument('--allow-insecure-localhost')
options.add_argument('--allow-running-insecure-content')

# options.set_capability('cloud:options', cloud_options)
browser = webdriver.Chrome(options=options)

The above block of code added before browser.get('https://sealed.sothebys.com') does absolutely nothing. How do I make my code work? I really really appreaciate any help and insights


r/inventwithpython • • Jul 19 '23

python ETL based project

1 Upvotes

currently i practice on one dumpy ETL based project.

in this project i used tools such as python, sql server, power BI application.

my doubts are, can i create staging area database and data warehouse database are else company create if incase company create how to find it both of them.

and after transfer the data into DW what will do next please share any one our experience like real sceneries. it will help full for my career and skills.


r/inventwithpython • • Jan 21 '23

PyPi Pip Installation

1 Upvotes

This may or may not be the best place to ask this question, but I recently installed Python 3.11 (latest) and using pip install automateboringstuff2ndedition gives numerous warnings of outdated installer dependencies. It also seems to not like the version of pillow that is outlined from automateboringstuff2ndedition 1.0.3. As an alternative I installed Pillow 9.4.0, but when I reran the 2nd edition pip install, I got a notice that it uninstalled Pillow 9.4.0. As a test then, I went to IDLE for 3.11 and import PIL worked just fine (no errors). Am I missing something? Should the 2nd edition pip installer be used for 3.11?

Pillow error:

RuntimeWarning: Pillow 9.0.0 does not support Python 3.11 and does not provide prebuilt Windows binaries. We do not recommend building from source on Windows.

Deprecation error (note I found this on another install as well, so it may not be 100% accurate to the 2nd edition pip install):

DEPRECATION: future is being installed using the legacy 'setup.py install' method, because it does not have a 'pyproject.toml' and the 'wheel' package is not installed. pip 23.1 will enforce this behaviour change. A possible replacement is to enable the '--use-pep517' option. Discussion can be found at https://github.com/pypa/pip/issues/8559 Running setup.py install for future ... done DEPRECATION: pefile is being installed using the legacy 'setup.py install' method, because it does not have a 'pyproject.toml' and the 'wheel' package is not installed. pip 23.1 will enforce this behaviour change. A possible replacement is to enable the '--use-pep517' option. Discussion can be found at https://github.com/pypa/pip/issues/8559

r/inventwithpython • • Sep 12 '21

IS EXTENDING HANGMAN SOURCE CODE INCORRECT?

1 Upvotes

Good day everyone,

I am currently on chapter 9 (Extending Hangman) of Invent Your Own Computer Games w/ Python.

This chapter is supposed to print "HANG MAN", asks player to choose a difficulty level, and choose a word from the dictionary.

When I run the code, I notice it does not ask me for the difficulty level, despite adding lines 106 to 116.

Is this accurate or is the code missing something?

  • while difficulty in 'EMH':

  • print('Enter difficulty: E - Easy, M - Medium, H - Hard')

  • difficulty = input().upper()

  • if difficulty == 'M':

  • del HANGMAN_PICS[8]

  • del HANGMAN_PICS[7]

  • if difficulty == 'H':

  • del HANGMAN_PICS[8]

  • del HANGMAN_PICS[7]

  • del HANGMAN_PICS[5]

  • del HANGMAN_PICS[3]


r/inventwithpython • • May 29 '20

Confused with python project

1 Upvotes

Hi. I am currently learning python through the book 'Automate the boring stuff'. In chapter 6, there is a multi-clipboard automatic messages project. I feel like I only understand basic python so far, like what are lists, dictionaries etc etc. When it comes to the projects, I am completely clueless and I have to always google and check out other people's programme.

Below is the project frm the book:

! python3

mclip.py - A multi-clipboard program.

TEXT = {'agree': """Yes, I agree. That sounds fine to me.""", 'busy': """Sorry, can we do this later this week or next week?""", 'upsell': """Would you consider making this a monthly donation?"""}

import sys, pyperclip if len(sys.argv) < 2: print('Usage: py mclip.py [keyphrase] - copy phrase text') sys.exit()

keyphrase = sys.argv[1] # first command line arg is the keyphrase

if keyphrase in TEXT: pyperclip.copy(TEXT[keyphrase]) print('Text for ' + keyphrase + ' copied to clipboard.') else: print('There is no text for ' + keyphrase)

That is the complete script and according to the book, we can now have a fast way to copy messages to the clipboard. However, I am very confused as to how to do it??? How do we copy messages quickly with this programme? For context, I am a Mac user.


r/inventwithpython • • May 03 '20

Please inform me!

1 Upvotes

Hi, I’ve started to read Automate the Boring Stuff second edition recently and I am on chapter 2/3, functions and all that. I am confused by ranges - Al, in the rock paper scissors game, makes it such that if random.zrandint(1,3) == 3: computerMove = “scissors”

or something like that. please don’t hate, just starting. why is this possible - doesn’t range(1,3) not include the number 3?

Thank you


r/inventwithpython • • Apr 02 '20

Help with pip install of 3rd Party Modules

1 Upvotes

Hi!

I have really been enjoying Automate the Boring Stuff with Python, although I have reached an impasse with installing 3rd party modules. I'm trying to install all the required modules using the pip command:

pip install --user –r automate-win-requirements.txt ––user

Yet I receive the error "no such file or directory," even though I have downloaded the automate-win-requirements.txt file and it is on my desktop. Here's a photo of the offending command prompt window.

I am clueless when it comes to programming in general and this pip install business is even worse. Hoping someone can help me get these modules installed and I'll be on my way to finishing chapter 6 and beyond. If someone has some resource suggestions of getting more literate with the terminal window and pip and other stuff that exists outside the Mu text editor, I'd appreciate that as well.

I tried googling the issue but my knowledge of terminals is so limited (nonexistent) that the resources were not helpful.

Thank a ton!

P.S. Somewhat unrelated, but as you can see in my imgur photo, the upgrade pip command did not work... does anyone know why this isn't working either?

UPDATE: Fixed this, I was a total CMD noob and didn't run the pip install in the folder that had automate-win-requirements.txt


r/inventwithpython • • Apr 01 '20

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

Thumbnail self.learnpython
1 Upvotes

r/inventwithpython • • Mar 19 '20

Problem with TaTeTi Game!

1 Upvotes

r/inventwithpython • • Dec 15 '19

python

1 Upvotes

i am trying to train data using Word2Vec Skip-Gram and i am getting an error which is below.

"UserWarning: C extension not loaded, training will be slow. Install a C compiler and reinstall gensim for fast training."

These are the tools i am using with Visual Studio Code

Genism 3.8.1

Python 3.8.0

conda 4.7.12

scipy 0.18.1

numpy 1.11.3


r/inventwithpython • • Dec 04 '19

Download Second edition

1 Upvotes

I bought the second edition book. How can I obtain the free PDF file?

Thanks

Ugo Donini


r/inventwithpython • • Dec 02 '19

Beginners double installing pip3 requirements.txt and single modules for Mu Editor

1 Upvotes

Hey there,

Just starting the 2nd Edition and right after starting the 1st Edition so switching from IDLE to Mu Editor. I attempted installing the 'automate-mac-requirements.txt' to the Mu Editior via the command line but it keeps failing.

The command I am using is: pip3 install --user –r automate-mac-requirements.txt --user - just as mentioned in the ebook but I am receiving the error: ERROR: Invalid requirement: '–r'

Alternatively, I tried installing just one module to the Mu Editor instead using this code: pip3 install --user -U send2trash==1.5.0 --target /Applications/mu-editor.app/Contents/Resources/app_packages .... but instead get this long error below:

Using cached https://files.pythonhosted.org/packages/49/46/c3dc27481d1cc57b9385aff41c474ceb7714f7935b1247194adae45db714/Send2Trash-1.5.0-py3-none-any.whl

Installing collected packages: send2trash

ERROR: Exception:

Traceback (most recent call last):

File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pip/_internal/cli/base_command.py", line 153, in _main

status = self.run(options, args)

File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pip/_internal/commands/install.py", line 446, in run

installed = install_given_reqs(

File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pip/_internal/req/__init__.py", line 58, in install_given_reqs

requirement.install(

File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pip/_internal/req/req_install.py", line 858, in install

self.move_wheel_files(

File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pip/_internal/req/req_install.py", line 487, in move_wheel_files

wheel.move_wheel_files(

File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pip/_internal/wheel.py", line 353, in move_wheel_files

scheme = distutils_scheme(

File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pip/_internal/locations.py", line 125, in distutils_scheme

i.finalize_options()

File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/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

Can anyone provide me an explanation as to what I am doing incorrectly? Much appreciated.


r/inventwithpython • • Oct 20 '19

Problem in Using selenium

1 Upvotes

I was going through the selenium part. Then I came to know that I need to download geckodriver and add it's path to the system variables to use it. It worked but now when I run the script, the geckodriver application pops up and sometime later empty Firefox tab opens up and nothing happens. It was the same with the 'bookcover' example. Any tips?


r/inventwithpython • • Oct 07 '19

Question about def function

1 Upvotes

Specifically from Invent Your Own Computer Games with Python, the first hangman game, starting at line 40.

I'm kind of fuzzy on def anyway, but this one confuses me a little. Where does wordList come in? The only time wordList is used is in this function. Why is it in the () on line 40, and what does the return function right below it actually do?


r/inventwithpython • • Oct 01 '19

Question on SMTP conncetion from the book Chapter 16

1 Upvotes

Hi

I am trying to connect to the SMTP server.

However, I am getting the below error :

ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it

# code is below :

import smtplib

conn = smtplib.SMTP('smtp-mail.outlook.com', 587)

I have searched online but couldn't find the answer to it

Can you please help


r/inventwithpython • • Sep 27 '19

MANY LINKS PROBLEM

1 Upvotes

There are so many links to download files from https://www.python.org/downloads/release/python-344/. Which I should choose??


r/inventwithpython • • Sep 08 '19

Question about the project in book "Automate the Boring Stuff with Python"

Post image
1 Upvotes

r/inventwithpython • • May 13 '19

a question about pygame.image.load()

1 Upvotes

Hi, Guys,

I tried the codes of Sound and Imgs in the book. However, I kept getting an error messeage: cannot open player.png when I ran pygame.image.load('player.png'). I looked up in the internet and tried the suggestion on os.path.join(), but it did not help. Could someone help me with this? Thanks a lot!

Hunter Wu


r/inventwithpython • • Apr 24 '19

Regex with 3 phone numbers in a row

1 Upvotes

Hello everyone! I am going crazy with a regex exercise. I am typing it exactly as I see it in the video, but when my string object is searched, the regex object is not recognized.

The exercise if from video 25:

This is what I type:

Please tell me what I am doing wrong, I am really confused (and I am one of those people who can't let go and just stop thinking about it before it's investigated thoroughly!!)


r/inventwithpython • • Apr 15 '19

I just finished chapter 5 of Invent Your Own Computer Games With Python and I decided to try to apply what I had learned. So I made this game. Thoughts?

1 Upvotes

If you prefer to read it on pastebin, here's the link. https://pastebin.com/qzdPU423

import time
slot = ['BAM!', 'click.', 'click.', 'click.', 'click.', 'click.']
dieMessage = ['You DIED! Thank goodness!', 'Good riddance.', 'My Condolences. You failed.', 'I will tell your parents that you died with honor.', 'I will tell your parents that you died for nothing.', 'Will somebody clean this up?']
surviveMessage = ['YEEEHAW! I ain\'t gon die today!', 'Thank heavens! You didn\'t get your brains blown out!', 'You have not died... YET.', 'This is getting intense.', 'Dang.', 'Maybe next time...']
def welcome():
    print('Welcome to Russian Roulette!')
    time.sleep(2)
    global peopleCount
    peopleCount = input('How many people are playing? (2-6): ')
    peopleCount = int(peopleCount)
    while int(peopleCount) < 2 or int(peopleCount) > 6:
        print('You must have at least 2 people and at most 6 people to play!')
        time.sleep(2)
        peopleCount = input('How many people are playing? (2-6): ')
    else:
        print('Please state your friends names, one at a time')
        if int(peopleCount) > 1:
            global person1
            person1 = input('Person #1: ')
            global person2
            person2 = input('Person #2: ')
            global choosePerson
            choosePerson = [person1, person2]
            if int(peopleCount) > 2:
                global person3
                person3 = input('Person #3: ')
                choosePerson = [person1, person2, person3]
                if int(peopleCount) > 3:
                    global person4
                    person4 = input('Person #4: ')
                    choosePerson = [person1, person2, person3, person4]
                    if int(peopleCount) > 4:
                        global person5
                        person5 = input('Person #5: ')
                        choosePerson = [person1, person2, person3, person4, person5]
                        if int(peopleCount) > 5:
                            global person6
                            person6 = input('Person #6: ')
                            choosePerson = [person1, person2, person3, person4, person5, person6]
            global choosePersonNum
            choosePersonNum = 10
            if int(peopleCount) == 2:
                print('Welcome, ' + person1 + ' and '  + person2 + '!')
                choosePersonNum = 10
                choosePersonNum = random.randint(0, 1)
            if int(peopleCount) == 3:
                print('Welcome, ' + person1 + ', '  + person2 + ', and ' + person3 + '!')
                choosePersonNum = 10
                choosePersonNum = random.randint(0, 2)
            if int(peopleCount) == 4:
                print('Welcome, ' + person1 + ', '  + person2 + ', ' + person3 + ', and '  + person4 + '!')
                choosePersonNum = 10
                choosePersonNum = random.randint(0, 3)
            if int(peopleCount) == 5:
                print('Welcome, ' + person1 + ', '  + person2 + ', ' + person3 + ', '  + person4 + ', and ' + person5 + '! ')
                choosePersonNum = 10
                choosePersonNum = random.randint(0, 4)
            if int(peopleCount) == 6:
                print('Welcome, ' + person1 + ', '  + person2 + ', ' + person3 + ', '  + person4 + ', ' + person5 + ', and ' + person6 + '! ')
                choosePersonNum = 10
                choosePersonNum = random.randint(0, 5)
def play():
    for i in range(7):
        global choosePersonNum
        if peopleCount == int(2):
            if i == 0:
                print('Ok! Let\'s begin!')
                time.sleep(2)
                print('It\'s ' + choosePerson[choosePersonNum] + 's turn')
                time.sleep(2)
                number = random.randint(0, 5)
                print (slot[number])
                time.sleep(2)
                if slot[number] == 'BAM!':
                    dieMessageNum = random.randint(0, 5)
                    print(dieMessage[dieMessageNum])
                    time.sleep(4)
                    break
                else:
                    surviveMessageNum = random.randint(0, 5)
                    print(surviveMessage[surviveMessageNum])
                    time.sleep(4)
                    choosePersonNum = choosePersonNum + 1
                    if choosePersonNum == 2:
                        choosePersonNum = 0
            if i == 1:
                print('It\'s ' + choosePerson[choosePersonNum] + 's turn')
                time.sleep(2)
                number = random.randint(0, 4)
                print (slot[number])
                time.sleep(2)
                if slot[number] == 'BAM!':
                    dieMessageNum = random.randint(0, 5)
                    print(dieMessage[dieMessageNum])
                    time.sleep(4)
                    break
                else:
                    surviveMessageNum = random.randint(0, 5)
                    print(surviveMessage[surviveMessageNum])
                    time.sleep(4)
                    choosePersonNum = choosePersonNum + 1
                    if choosePersonNum == 2:
                        choosePersonNum = 0
            if i == 2:
                print('It\'s ' + choosePerson[choosePersonNum] + 's turn')
                time.sleep(2)
                number = random.randint(0, 3)
                print (slot[number])
                time.sleep(2)
                if slot[number] == 'BAM!':
                    dieMessageNum = random.randint(0, 5)
                    print(dieMessage[dieMessageNum])
                    time.sleep(4)
                    break
                else:
                    surviveMessageNum = random.randint(0, 5)
                    print(surviveMessage[surviveMessageNum])
                    time.sleep(4)
                    choosePersonNum = choosePersonNum + 1
                    if choosePersonNum == 2:
                        choosePersonNum = 0
            if i == 3:
                print('It\'s ' + choosePerson[choosePersonNum] + 's turn')
                time.sleep(2)
                number = random.randint(0, 2)
                print (slot[number])
                time.sleep(2)
                if slot[number] == 'BAM!':
                    dieMessageNum = random.randint(0, 5)
                    print(dieMessage[dieMessageNum])
                    time.sleep(2)
                    break
                else:
                    surviveMessageNum = random.randint(0, 5)
                    print(surviveMessage[surviveMessageNum])
                    time.sleep(2)
                    choosePersonNum = choosePersonNum + 1
                    if choosePersonNum == 2:
                        choosePersonNum = 0
            if i == 4:
                time.sleep(2)
                print('It\'s ' + choosePerson[choosePersonNum] + 's turn')
                time.sleep(2)
                number = random.randint(0, 1)
                print (slot[number])
                time.sleep(2)
                if slot[number] == 'BAM!':
                    dieMessageNum = random.randint(0, 5)
                    print(dieMessage[dieMessageNum])
                    time.sleep(2)
                    break
                else:
                    surviveMessageNum = random.randint(0, 5)
                    print(surviveMessage[surviveMessageNum])
                    time.sleep(2)
                    choosePersonNum = choosePersonNum + 1
                    if choosePersonNum == 2:
                        choosePersonNum = 0
            if i == 5:
                time.sleep(2)
                print('It\'s ' + choosePerson[choosePersonNum] + 's turn')
                time.sleep(2)
                number = random.randint(0, 0)
                print (slot[number])
                time.sleep(2)
                if slot[number] == 'BAM!':
                    dieMessageNum = random.randint(0, 0)
                    print(dieMessage[dieMessageNum])
                    time.sleep(2)
                else:
                    surviveMessageNum = random.randint(0, 5)
                    print(surviveMessage[surviveMessageNum])
                    time.sleep(2)
                    choosePersonNum = choosePersonNum + 1
                    if choosePersonNum == 2:
                        choosePersonNum = 0
        if peopleCount == 3:
            if i == 0:
                 print('Ok! Let\'s begin!')
                 time.sleep(2)
                 print('It\'s ' + choosePerson[choosePersonNum] + 's turn')
                 time.sleep(2)
                 number = random.randint(0, 5)
                 print (slot[number])
                 time.sleep(2)
                 if slot[number] == 'BAM!':
                     dieMessageNum = random.randint(0, 5)
                     print(dieMessage[dieMessageNum])
                     time.sleep(2)
                     break
                 else:
                     surviveMessageNum = random.randint(0, 5)
                     print(surviveMessage[surviveMessageNum])
                     time.sleep(2)
                     choosePersonNum = choosePersonNum + 1
                     if choosePersonNum == 3:
                         choosePersonNum = 0
            if i == 1:
                time.sleep(2)
                print('It\'s ' + choosePerson[choosePersonNum] + 's turn')
                time.sleep(2)
                number = random.randint(0, 4)
                print (slot[number])
                time.sleep(2)
                if slot[number] == 'BAM!':
                    dieMessageNum = random.randint(0, 5)
                    print(dieMessage[dieMessageNum])
                    time.sleep(2)
                    break
                else:
                    surviveMessageNum = random.randint(0, 5)
                    print(surviveMessage[surviveMessageNum])
                    time.sleep(2)
                    choosePersonNum = choosePersonNum + 1
                    if choosePersonNum == 3:
                        choosePersonNum = 0
            if i == 2:
                time.sleep(2)
                print('It\'s ' + choosePerson[choosePersonNum] + 's turn')
                time.sleep(2)
                number = random.randint(0, 3)
                print (slot[number])
                time.sleep(2)
                if slot[number] == 'BAM!':
                    dieMessageNum = random.randint(0, 5)
                    print(dieMessage[dieMessageNum])
                    time.sleep(2)
                    break
                else:
                    surviveMessageNum = random.randint(0, 5)
                    print(surviveMessage[surviveMessageNum])
                    time.sleep(2)
                    choosePersonNum = choosePersonNum + 1
                    if choosePersonNum == 3:
                        choosePersonNum = 0
            if i == 3:
                time.sleep(2)
                print('It\'s ' + choosePerson[choosePersonNum] + 's turn')
                time.sleep(2)
                number = random.randint(0, 2)
                print (slot[number])
                time.sleep(2)
                if slot[number] == 'BAM!':
                    dieMessageNum = random.randint(0, 5)
                    print(dieMessage[dieMessageNum])
                    time.sleep(2)
                    break
                else:
                    surviveMessageNum = random.randint(0, 5)
                    print(surviveMessage[surviveMessageNum])
                    time.sleep(2)
                    choosePersonNum = choosePersonNum + 1
                    if choosePersonNum == 3:
                        choosePersonNum = 0
            if i == 4:
                time.sleep(2)
                print('It\'s ' + choosePerson[choosePersonNum] + 's turn')
                time.sleep(2)
                number = random.randint(0, 1)
                print (slot[number])
                time.sleep(2)
                if slot[number] == 'BAM!':
                    dieMessageNum = random.randint(0, 5)
                    print(dieMessage[dieMessageNum])
                    time.sleep(2)
                    break
                else:
                    surviveMessageNum = random.randint(0, 5)
                    print(surviveMessage[surviveMessageNum])
                    time.sleep(2)
                    choosePersonNum = choosePersonNum + 1
                    if choosePersonNum == 3:
                        choosePersonNum = 0
            if i == 5:
                time.sleep(2)
                print('It\'s ' + choosePerson[choosePersonNum] + 's turn')
                time.sleep(2)
                number = random.randint(0, 0)
                print (slot[number])
                time.sleep(2)
                if slot[number] == 'BAM!':
                    dieMessageNum = random.randint(0, 5)
                    print(dieMessage[dieMessageNum])
                    time.sleep(2)
                    break
                else:
                    surviveMessageNum = random.randint(0, 5)
                    print(surviveMessage[surviveMessageNum])
                    time.sleep(2)
                    choosePersonNum = choosePersonNum + 1
                    if choosePersonNum == 3:
                        choosePersonNum = 0
        if peopleCount == 4:
            if i == 0:
                 print('Ok! Let\'s begin!')
                 time.sleep(2)
                 print('It\'s ' + choosePerson[choosePersonNum] + 's turn')
                 time.sleep(2)
                 number = random.randint(0, 5)
                 print (slot[number])
                 time.sleep(2)
                 if slot[number] == 'BAM!':
                     dieMessageNum = random.randint(0, 5)
                     print(dieMessage[dieMessageNum])
                     time.sleep(2)
                     break
                 else:
                     surviveMessageNum = random.randint(0, 5)
                     print(surviveMessage[surviveMessageNum])
                     time.sleep(2)
                     choosePersonNum = choosePersonNum + 1
                     if choosePersonNum == 4:
                         choosePersonNum = 0
            if i == 1:
                time.sleep(2)
                print('It\'s ' + choosePerson[choosePersonNum] + 's turn')
                time.sleep(2)
                number = random.randint(0, 4)
                print (slot[number])
                time.sleep(2)
                if slot[number] == 'BAM!':
                    dieMessageNum = random.randint(0, 5)
                    print(dieMessage[dieMessageNum])
                    time.sleep(2)
                    break
                else:
                    surviveMessageNum = random.randint(0, 5)
                    print(surviveMessage[surviveMessageNum])
                    time.sleep(2)
                    choosePersonNum = choosePersonNum + 1
                    if choosePersonNum == 4:
                        choosePersonNum = 0
            if i == 2:
                time.sleep(2)
                print('It\'s ' + choosePerson[choosePersonNum] + 's turn')
                time.sleep(2)
                number = random.randint(0, 3)
                print (slot[number])
                time.sleep(2)
                if slot[number] == 'BAM!':
                    dieMessageNum = random.randint(0, 5)
                    print(dieMessage[dieMessageNum])
                    time.sleep(2)
                    break
                else:
                    surviveMessageNum = random.randint(0, 5)
                    print(surviveMessage[surviveMessageNum])
                    time.sleep(2)
                    choosePersonNum = choosePersonNum + 1
                    if choosePersonNum == 4:
                        choosePersonNum = 0
            if i == 3:
                time.sleep(2)
                print('It\'s ' + choosePerson[choosePersonNum] + 's turn')
                time.sleep(2)
                number = random.randint(0, 2)
                print (slot[number])
                time.sleep(2)
                if slot[number] == 'BAM!':
                    dieMessageNum = random.randint(0, 5)
                    print(dieMessage[dieMessageNum])
                    time.sleep(2)
                    break
                else:
                    surviveMessageNum = random.randint(0, 5)
                    print(surviveMessage[surviveMessageNum])
                    time.sleep(2)
                    choosePersonNum = choosePersonNum + 1
                    if choosePersonNum == 4:
                        choosePersonNum = 0
            if i == 4:
                time.sleep(2)
                print('It\'s ' + choosePerson[choosePersonNum] + 's turn')
                time.sleep(2)
                number = random.randint(0, 1)
                print (slot[number])
                time.sleep(2)
                if slot[number] == 'BAM!':
                    dieMessageNum = random.randint(0, 5)
                    print(dieMessage[dieMessageNum])
                    time.sleep(2)
                    break
                else:
                    surviveMessageNum = random.randint(0, 5)
                    print(surviveMessage[surviveMessageNum])
                    time.sleep(2)
                    choosePersonNum = choosePersonNum + 1
                    if choosePersonNum == 4:
                        choosePersonNum = 0
            if i == 5:
                time.sleep(2)
                print('It\'s ' + choosePerson[choosePersonNum] + 's turn')
                time.sleep(2)
                number = random.randint(0, 0)
                print (slot[number])
                time.sleep(2)
                if slot[number] == 'BAM!':
                    dieMessageNum = random.randint(0, 5)
                    print(dieMessage[dieMessageNum])
                    time.sleep(2)
                    break
                else:
                    surviveMessageNum = random.randint(0, 5)
                    print(surviveMessage[surviveMessageNum])
                    time.sleep(2)
                    choosePersonNum = choosePersonNum + 1
                    if choosePersonNum == 4:
                        choosePersonNum = 0
        if peopleCount == 5:
            if i == 0:
                 print('Ok! Let\'s begin!')
                 time.sleep(2)
                 print('It\'s ' + choosePerson[choosePersonNum] + 's turn')
                 time.sleep(2)
                 number = random.randint(0, 5)
                 print (slot[number])
                 time.sleep(2)
                 if slot[number] == 'BAM!':
                     dieMessageNum = random.randint(0, 5)
                     print(dieMessage[dieMessageNum])
                     time.sleep(2)
                     break
                 else:
                     surviveMessageNum = random.randint(0, 5)
                     print(surviveMessage[surviveMessageNum])
                     time.sleep(2)
                     choosePersonNum = choosePersonNum + 1
                     if choosePersonNum == 5:
                         choosePersonNum = 0
            if i == 1:
                time.sleep(2)
                print('It\'s ' + choosePerson[choosePersonNum] + 's turn')
                time.sleep(2)
                number = random.randint(0, 4)
                print (slot[number])
                time.sleep(2)
                if slot[number] == 'BAM!':
                    dieMessageNum = random.randint(0, 5)
                    print(dieMessage[dieMessageNum])
                    time.sleep(2)
                    break
                else:
                    surviveMessageNum = random.randint(0, 5)
                    print(surviveMessage[surviveMessageNum])
                    time.sleep(2)
                    choosePersonNum = choosePersonNum + 1
                    if choosePersonNum == 5:
                        choosePersonNum = 0
            if i == 2:
                time.sleep(2)
                print('It\'s ' + choosePerson[choosePersonNum] + 's turn')
                time.sleep(2)
                number = random.randint(0, 3)
                print (slot[number])
                time.sleep(2)
                if slot[number] == 'BAM!':
                    dieMessageNum = random.randint(0, 5)
                    print(dieMessage[dieMessageNum])
                    time.sleep(2)
                    break
                else:
                    surviveMessageNum = random.randint(0, 5)
                    print(surviveMessage[surviveMessageNum])
                    time.sleep(2)
                    choosePersonNum = choosePersonNum + 1
                    if choosePersonNum == 5:
                        choosePersonNum = 0
            if i == 3:
                time.sleep(2)
                print('It\'s ' + choosePerson[choosePersonNum] + 's turn')
                time.sleep(2)
                number = random.randint(0, 2)
                print (slot[number])
                time.sleep(2)
                if slot[number] == 'BAM!':
                    dieMessageNum = random.randint(0, 5)
                    print(dieMessage[dieMessageNum])
                    time.sleep(2)
                    break
                else:
                    surviveMessageNum = random.randint(0, 5)
                    print(surviveMessage[surviveMessageNum])
                    time.sleep(2)
                    choosePersonNum = choosePersonNum + 1
                    if choosePersonNum == 5:
                        choosePersonNum = 0
            if i == 4:
                time.sleep(2)
                print('It\'s ' + choosePerson[choosePersonNum] + 's turn')
                time.sleep(2)
                number = random.randint(0, 1)
                print (slot[number])
                time.sleep(2)
                if slot[number] == 'BAM!':
                    dieMessageNum = random.randint(0, 5)
                    print(dieMessage[dieMessageNum])
                    time.sleep(2)
                    break
                else:
                    surviveMessageNum = random.randint(0, 5)
                    print(surviveMessage[surviveMessageNum])
                    time.sleep(2)
                    choosePersonNum = choosePersonNum + 1
                    if choosePersonNum == 5:
                        choosePersonNum = 0
            if i == 5:
                time.sleep(2)
                print('It\'s ' + choosePerson[choosePersonNum] + 's turn')
                time.sleep(2)
                number = random.randint(0, 0)
                print (slot[number])
                time.sleep(2)
                if slot[number] == 'BAM!':
                    dieMessageNum = random.randint(0, 5)
                    print(dieMessage[dieMessageNum])
                    time.sleep(2)
                    break
                else:
                    surviveMessageNum = random.randint(0, 5)
                    print(surviveMessage[surviveMessageNum])
                    time.sleep(2)
                    choosePersonNum = choosePersonNum + 1
                    if choosePersonNum == 5:
                        choosePersonNum = 0
        if peopleCount == 6:
            if i == 0:
                 print('Ok! Let\'s begin!')
                 time.sleep(2)
                 print('It\'s ' + choosePerson[choosePersonNum] + 's turn')
                 time.sleep(2)
                 number = random.randint(0, 5)
                 print (slot[number])
                 time.sleep(2)
                 if slot[number] == 'BAM!':
                     dieMessageNum = random.randint(0, 5)
                     print(dieMessage[dieMessageNum])
                     time.sleep(2)
                     break
                 else:
                     surviveMessageNum = random.randint(0, 5)
                     print(surviveMessage[surviveMessageNum])
                     time.sleep(2)
                     choosePersonNum = choosePersonNum + 1
                     if choosePersonNum == 6:
                         choosePersonNum = 0
            if i == 1:
                time.sleep(2)
                print('It\'s ' + choosePerson[choosePersonNum] + 's turn')
                time.sleep(2)
                number = random.randint(0, 4)
                print (slot[number])
                time.sleep(2)
                if slot[number] == 'BAM!':
                    dieMessageNum = random.randint(0, 5)
                    print(dieMessage[dieMessageNum])
                    time.sleep(2)
                    break
                else:
                    surviveMessageNum = random.randint(0, 5)
                    print(surviveMessage[surviveMessageNum])
                    time.sleep(2)
                    choosePersonNum = choosePersonNum + 1
                    if choosePersonNum == 6:
                        choosePersonNum = 0
            if i == 2:
                time.sleep(2)
                print('It\'s ' + choosePerson[choosePersonNum] + 's turn')
                time.sleep(2)
                number = random.randint(0, 3)
                print (slot[number])
                time.sleep(2)
                if slot[number] == 'BAM!':
                    dieMessageNum = random.randint(0, 5)
                    print(dieMessage[dieMessageNum])
                    time.sleep(2)
                    break
                else:
                    surviveMessageNum = random.randint(0, 5)
                    print(surviveMessage[surviveMessageNum])
                    time.sleep(2)
                    choosePersonNum = choosePersonNum + 1
                    if choosePersonNum == 6:
                        choosePersonNum = 0
            if i == 3:
                time.sleep(2)
                print('It\'s ' + choosePerson[choosePersonNum] + 's turn')
                time.sleep(2)
                number = random.randint(0, 2)
                print (slot[number])
                time.sleep(2)
                if slot[number] == 'BAM!':
                    dieMessageNum = random.randint(0, 5)
                    print(dieMessage[dieMessageNum])
                    time.sleep(2)
                    break
                else:
                    surviveMessageNum = random.randint(0, 5)
                    print(surviveMessage[surviveMessageNum])
                    time.sleep(2)
                    choosePersonNum = choosePersonNum + 1
                    if choosePersonNum == 6:
                        choosePersonNum = 0
            if i == 4:
                time.sleep(2)
                print('It\'s ' + choosePerson[choosePersonNum] + 's turn')
                time.sleep(2)
                number = random.randint(0, 1)
                print (slot[number])
                time.sleep(2)
                if slot[number] == 'BAM!':
                    dieMessageNum = random.randint(0, 5)
                    print(dieMessage[dieMessageNum])
                    time.sleep(2)
                    break
                else:
                    surviveMessageNum = random.randint(0, 5)
                    print(surviveMessage[surviveMessageNum])
                    time.sleep(2)
                    choosePersonNum = choosePersonNum + 1
                    if choosePersonNum == 6:
                        choosePersonNum = 0
            if i == 5:
                time.sleep(2)
                print('It\'s ' + choosePerson[choosePersonNum] + 's turn')
                time.sleep(2)
                number = random.randint(0, 0)
                print (slot[number])
                time.sleep(2)
                if slot[number] == 'BAM!':
                    dieMessageNum = random.randint(0, 5)
                    print(dieMessage[dieMessageNum])
                    time.sleep(2)
                    break
                else:
                    surviveMessageNum = random.randint(0, 5)
                    print(surviveMessage[surviveMessageNum])
                    time.sleep(2)
                    choosePersonNum = choosePersonNum + 1
                    if choosePersonNum == 6:
                        choosePersonNum = 0
playAgain = 'y'
while playAgain == 'yes' or playAgain == 'Yes' or playAgain == 'y':
    welcome()
    play()
    print('Would you like to play again?')
    playAgain = input()

r/inventwithpython • • Mar 18 '19

Check out the Bulk Mailer made with python! No API key required!

Thumbnail
youtube.com
1 Upvotes

r/inventwithpython • • Mar 02 '19

ATBS mapit program problem

1 Upvotes

So I've done the mapit program, and i'm having an issue. It runs just fine in pycharm when drawing the address from the clipboard. However, it doesn't work right when trying to run it in the command line. But when I execute it in command line, pycharm responds to it (with the icon on the taskbar going orange as they do on Windows for a notification). I can't figure out why it's doing this. the tab is just never opened. Anyone know what is going on?


r/inventwithpython • • Jan 18 '19

Encrypt email message and forward

1 Upvotes

Hi there,

I am new to this forum. Hope, i get guidance/advise from any one of you on my requirement. My req. is, I need to develop a python script which will read the emails received on the email server encrypt them and forward to destination email server/address. The email server which i want to read from is kind of mediator between two or many other email servers. Can someone guide me as to how to approach this read, encrypt and forward part in python.

Thanks in advance.


r/inventwithpython • • Jan 17 '19

Strange problem with Hangman project

1 Upvotes

Hiyo,

I've got a some what interesting problem with the extended hangman game project.

It runs fine, but if the player guesses the first letter of the secret word, the game ends, thinking the player has won.

For example if the word is "Purple" and the player guesses P, the game ends, even if they haven't guessed the other letters. I'm still very new to programming so I don't really know what would be causing this issue.

Any help would be greatly appreciated.

https://pastebin.com/hPBTbqB6