r/pythonhelp • • Apr 18 '22

Assignment advice

2 Upvotes

Hi! I have been having trouble with this assignment problem. If anyone can help me with this I would greatly appreciate it.

The program says to write a function that accepts a string of arbitrary length as an argument and it should print out a list where each character in the original string is repeated and capitalized.

Call the function upper(my_string)

Example upper(“hi”)

[‘HH’, ‘II’]


r/pythonhelp • • Apr 14 '22

well this my first attempt at a shitty game. all tips and criticism accepted.

2 Upvotes

this is my first attempt at a shitty game. its slots. i have several bugs i need a bit of help and re writing.

criticism is accepted and tips also. not tried games so be a bit easy......lol

from random import randint
from os import system

class Machine():
    def __init__(self, w1, w2,w3, credits, bet, jp, min):
        self.w1 = w1
        self.w2 = w2 
        self.w3 = w3 
        self.credits = credits
        self.bet = bet
        self.jp = jp 
        self.min = min
    def stat(self):
        print('\n\n\n\n--------------------------------------')
        print('JackPot:    $',self.jp)
        print('Mini Pot:   $', self.min)
        print('Credits:    $', self.credits)
        print('Bet:        $', self.bet)
        print('--------------------------------------')
        print('\ns = spin  l = lower  r = raise bet   h = help\n\n')
        print('---------------------------------------------')
        print('-    ', self.w1, ' |    ', self.w2,'     |     ', self.w3)
        print('---------------------------------------------\n\n')
        if (self.w1 == self.w2 and self.w1 == self.w3):
            if (self.w1 == 'Jack Pot'):
                print('Jackpot!!!!!!  you win $', self.jp, '!!!!!!!!!!!!!!!!!!')
                self.credits += self.jp * self.bet
                self.jp = 1000
            if (self.w1 == 'Buffalo'):
                print('Buffalo!  you win $', self.min)
                self.credits += self.min * self.bet
                self.min = 500
            if (self.w1 == 'Bear'):
                win = randint(81, 100)
                print('you win $', win)
                self.credits += win * self.bet
            if (self.w1 == 'Cherry'):
                win = randint(51, 80)
                print('you win $', win)
                self.credits += win * self.bet
            if (self.w1 == 'Bell'):
                win = randint(11, 50)
                print('you win $', win)
                self.credits += win * self.bet
            if (self.w1 == 'Hat'):
                win = randint(3,10)
                print('you win $', win)
                self.credits += win * self.bet
            if (self.w1 == 'Bar'):
                print('you win $', self.bet)
                self.credits += self.bet
            if (self.w1 == ''):
                print('Get Ready To Win!!!!')
    def htp(self):
        print('***************************************************')
        print('\nJackpot / Jackpot / Jackpot =  jackpot * bet')
        print('Buffalo / Buffalo / Buffalo = Mini Pot * bet')
        print('Bear  /  Bear  /  Bear  =    $81 - $100   * bet')
        print('Cherry / Cherry / Cherry =  $51 - $80 * bet')
        print('Bell / Bell / Bell =  $11 - $50 * bet')
        print('Hat  /  Hat  /  Hat =  $3 - $10 * bet')
        print('Bar / Bar / Bar = $' ,self.bet)
        print('**************************************************\n')
        input('\npress enter........')
    def spin(self, wheel1, wheel2, wheel3):
        self.min += randint(0,20)
        self.jp += randint(0,20)
        self.credits -= self.bet
        self.w1 = wheel1
        self.w2 = wheel2
        self.w3 = wheel3
    def Raise(self):
        if (self.bet > self.credits):
            print('sorry your broke af dude')
        else:
            self.bet += 1
            print('raised bet by $1')
    def Lower(self):
        if (self.bet == 1):
            print('sorry you cant lower your bet...')
        else:
            self.bet -= 1
Items = ['Jack Pot', 'Buffalo', 'Bear', 'Cherry', 'Bell', 'Hat', 'Bar' ]
Items2 = ['Buffalo', 'Cherry', 'Hat', 'Bell', 'Jack Pot', 'Bear', 'Bar' ]
Items3 = ['Bell', 'Hat', 'Bear', 'Jack Pot', 'Buffalo', 'Cherry', 'Bear' ]
Slots = Machine('','','',100, 1, 1000,500)
while Slots.credits > 0:
    system('cls')
    Slots.stat()
    P_input = input('---->  :  ')
    if P_input == 's' or P_input == 'S':
        Slots.spin(Items[randint(0,6)], Items2[randint(0,6)], Items3[randint(0,6)])
    if P_input == 'h' or P_input == 'H':
        Slots.htp()
    if P_input == 'l' or P_input == 'L':
        Slots.Lower()
    if P_input == 'r' or P_input == 'R':
        Slots.Raise()

r/pythonhelp • • Mar 17 '22

hey guys im having some problems with b trees I have to implement the remove function but first of all I do not know if I am doing this ok

2 Upvotes
def remove(self, key):
    if (self.root == self.isLeaf+1 and self.root == key):
        self.root = None
        return True
 
    cur = self.root

    while (cur != None):
      if(cur == key and cur != self.root):
        cur = cur + 1

    keyIndex = remove(cur, key)
      if(keyIndex is not -1):
        if(cur == self.isLeaf):
          remove(cur, keyIndex)
          return true

        tmpChild = remove(cur, keyIndex + 1)
        tmpKey = BTreeGetMinKey(tmpChild)
        remove(self, tmpKey)
        BTreeKeySwap(self.root, key, tmpKey)
        return true
    
      cur = BTreeNextNode(cur, key)
      return false

def __init__(self, orders, key=[], child=[], Leaf=True):
    self.orders = orders
    self.key = key
    self.child = child
    self.Leaf = Leaf

here are some of my errors

File "/****/****/****/****/*****", line 109

if(keyIndex is not -1):

IndentationError: unexpected indent

thank you all


r/pythonhelp • • Mar 17 '22

How to print numbers from 1-100 that are only divisible by 1 and itself

2 Upvotes

Hi, I'm making a project where I'm making all the numbers from 1 - 100 that are divisible by 1 and itself to print. e.g(7) I want the numbers to be full numbers, no decimals. I currently have code that prints the numbers that are divisible by other numbers. such as 4. this is my code so far.

xdx = []

for x in range(1, 101):

for y in range(2, x):

if x % y == 0:

xdx.append(x)

break

print(xdx)

Ya um tabs dont work in reddit for some reaoson so uh ya.


r/pythonhelp • • Mar 17 '22

Program that matches the BPM of two audio files with Dynamic Time Warping

2 Upvotes

Hello,

I have been trying to execute the program detailed in this thread to no avail. I was wondering if another feasible method exists to:

  • Input two songs

  • Calculate the bpm of each one (down to the induvidual beat, not an average)

  • Match the BPM of both audio files with Dynamic Time Warping

  • Output the two audio files now with identical BPMs

If you know of one or how I would write one, let me know. Thanks


r/pythonhelp • • Mar 11 '22

SOLVED Problem with variables in for loop not working outside of the loop

2 Upvotes

I'm self taught on Python, and this exact issue has had me stumped for 2 days now. Normally enough googling fixes it, but I cannot get this fixed, and it's driving me crazy. It's got to be something simple, but what???

I have a seperate python app that creates a CSV from a restAPI. I then use the following code to be able to search (and eventually do equations) within the CSV that was downloaded. This is just the beginning of the project, I'm just trying to get data from the CSV file to populate in one of the tkinter Entry boxes for now, but I get errors saying "NameError: name 'ha' is not defined". Except it is defined (I thought), and to my knowledge, the scope of a variable created within the for loop is not a local variable, and should therefore fall under "Class MyWindow:", right?

Also, I know I should be using "while open" statements for the 2 CSV files, but I was concerned that was causing a problem so I changed it for now.

import string
from tkinter import *
import csv
from operator import eq
import os

class MyWindow:
    def __init__(self, win):
        self.lbl1=Label(win, text='Item Name')
        self.lbl1.place(x=150, y=20)
        self.lblname=Label(win, text='Name')
        self.lblname.place(x=50, y=100)
        self.lblha=Label(win, text='High Alch')
        self.lblha.place(x=50, y=120)
        self.lbl3=Label(win, text='Result')
        self.lbl3.place(x=100, y=200)
        self.t1=Entry(bd=3)
        self.t1.place(x=150, y=50)
        self.tname=Entry()
        self.tname.place(x=100, y=100)
        self.tha=Entry()
        self.tha.place(x=100, y=120)
        self.t3=Entry()
        self.t3.place(x=200, y=200)
        self.b1=Button(win, text='Submit', command=self.search)
        self.b1.place(x=280, y=50)

    def search(self):
        file = open('1h.csv', 'r')
        rsfile = open('mapping.csv', 'r')
        reader = csv.reader(file)
        rsmap = csv.reader(rsfile)
        self.tname.delete(0, 'end')
        self.tha.delete(0, 'end')
        self.t3.delete(0, 'end')

        for row in rsmap:
            if self.t1 == row[8]:
                self.tname = row[8]
                self.ha = row[6] #THIS IS THE DECLARATION IM REFERRING TO
                self.limit = row[4]
                self.itemid = row[1]
                self.t3.insert(END, str(self.name))
        for row in reader:
            if '561' == row[0]:
                self.naturecost = row[3]
                self.Naturecost = float(self.naturecost)
            if self.t1 == row[0]:
                self.hourlow = row[3]
                self.Hourlow = float(hourlow)
                self.hourvol = row[4]
                self.t1=row[0]

        iname=self.t1.get()
        self.tname.insert(END, str(self.ha)) #DOES NOT WORK
        self.t3.insert(END, str(iname)) #DOES WORK
        file.close()
        rsfile.close()

window=Tk()
mywin=MyWindow(window)
window.title('Hello Python')
window.geometry("400x300+10+10")
window.mainloop()

r/pythonhelp • • Mar 09 '22

SOLVED My program doesn't work on Windows

2 Upvotes

So I have written a simple python program in Linux and converted it into an .exe file using pyinstaller. It works flawlessly on Linux but when I try running it in windows (program opens in a CMD window) I am able to input required values but then it instantly crashes (it should print some stuff every 10 seconds).

If anybody knows how I would be able to fix this please leave a comment below :)

(If you think the problem is in code I will be happy to paste it)

Edit:

Libraries are:

-os, socket, datetime, requests, time, pytz (to get the correct time zone) | (I don't know for any dependencies they have)

Edit 2:

It all came down to a simple error with one character in my code (this one =>● ) I didn't assume that it would be a source of my problem because the first lines were executed properly even though they contained this character.


r/pythonhelp • • Mar 08 '22

fat file, but missing compatible architecture have 'i386,x86_64', need 'arm64e' with bcrypt on Mac M1 Pro chip

2 Upvotes

I have recently upgraded from a 2017 MBP to a 2021 MBP with the M1 Pro chip.

Since then i've had issue running a Python 2.7 script.

I am using paramiko:

```

#!/usr/bin/env python
...
import paramiko
...

...and when I run the script I get the following error:

```

Traceback (most recent call last):
  File "/Users/crmpicco/deploy.py", line 14, in <module>
    import paramiko
  File "/Library/Python/2.7/site-packages/paramiko/__init__.py", line 22, in <module>
    from paramiko.transport import SecurityOptions, Transport
  File "/Library/Python/2.7/site-packages/paramiko/transport.py", line 90, in <module>
    from paramiko.ed25519key import Ed25519Key
  File "/Library/Python/2.7/site-packages/paramiko/ed25519key.py", line 17, in <module>
    import bcrypt
  File "/Library/Python/2.7/site-packages/bcrypt/__init__.py", line 25, in <module>
    from bcrypt import _bcrypt
ImportError: dlopen(/Library/Python/2.7/site-packages/bcrypt/_bcrypt.so, 0x0002): tried: '/Library/Python/2.7/site-packages/bcrypt/_bcrypt.so' (fat file, but missing compatible architecture (have 'i386,x86_64', need 'arm64e')), '/usr/lib/_bcrypt.so' (no such file)

```

The file definitely exists, as the error says, but i'm unsure how to proceed.

```

locate bcrypt.so
/Library/Python/2.7/site-packages/bcrypt/_bcrypt.so

r/pythonhelp • • Feb 19 '22

pip3 install -r requirements.txt not working

2 Upvotes

Hello,

I have never dealt with Python before so this could be just a simple problem: I'm trying to run this Python code and step 2 is to install libaries with "pip3 install -r requirements.txt", but every time I type this in my console I get no feedback, whats the problem? I think I'm doing something wrong with installing the libraries because when I type "instalooter login" in step 3 I get an error message "zsh: command not found: instalooter".

Terminal: https://drive.google.com/file/d/1YjY4bmPaqOXjuCsHQ8NLHbyceTTjmIXC/view?usp=sharing

Python code: https://github.com/nathan-149/automated_youtube_channel


r/pythonhelp • • Feb 18 '22

Trying to split a sentence into words. Where did I go wrong?

2 Upvotes

beginner python learner here and trying to return these words into strings not seeing where I am going wrong.

def separate(sentence):

words = ",".split(sentence)

return words

separate('Hello, how are you?') == ['Hello,', 'how', 'are', 'you?']

output comes out as false. help please


r/pythonhelp • • Feb 16 '22

HOMEWORK Module issue while running Sparrow WiFi

2 Upvotes

I recently tried t run Sparrow WiFi ( https://github.com/ghostop14/sparrow-wifi ) but some python module returned an error which i couldn't figure out. Plz help to fix this.

Traceback (most recent call last):

File "/home/lucifer/Tools/sparrow-wifi/sparrow-wifi.py", line 33, in <module>

from PyQt5.QtWidgets import QApplication, QMainWindow, QDesktopWidget, QGraphicsSimpleTextItem, QFrame, QGraphicsView

RuntimeError: the sip module implements API v12.0 to v12.8 but the PyQt5.QtWidgets module requires API v12.9


r/pythonhelp • • Jan 21 '22

Unknown use of Function

2 Upvotes

Hi, i've been working on recognising algorithms and what they do, but im stuck on this one

i understand that this is a square calculator, and the last for loop is the comparitive to identify if too values multplied are square, but its the first part thats confusing me

thanks in advance

def newfunc(Ai)
    s = np.shape(Ai)
    Bi = np.zeros((s[0],s[0]))
    BDiag = []
    for i in range(s[0]):
        for j in range(s[0]):
            Bi[i,j] = j*Ai[i]
    for i in range(s[0]):
        if Bi[i,j] < i**2:
            BDiag.append('less')
        elif Bi[i,j] > i**2:
            BDiag.append('more')
        elif Bi[i,j] == i**2:
            BDiag.append('square')
    return BDiag

r/pythonhelp • • Jan 08 '22

Let's Solve Wordle

2 Upvotes

There is a game called Worlde where you have to guess the 5 letter word. I want to know if you can solve it for every answer after 3 guesses (so on your fourth guess).

  • There are 2315 possible answer words.

  • There are 12972 words you can use to guess.

Every guess gives you information on each letter:

  • Letter does not exist in word.

  • Letter exists but not in correct place.

  • Letter correct and in correct place.

My intuition tells me an algorithm should be able to know the word after 3 guesses every time.

But I'm not sure how to program it. Any ideas?

-----------------------

My thoughts are: you go through each possible starting word:

And for each answer, there will be a set of other possible answers.

So see if, with 2 additional guesses, you can always uniquely identify each of these possible other answers. So with a 2nd guess word, followed by a 3rd guess word, depending on the information gathered from the 2nd guess word.

So see if there is a 1st guess that, combined with 2nd and 3rd guesses you can always uniquely identify the Answer.


r/pythonhelp • • Dec 01 '21

How to sort whole strings alphabetically?

2 Upvotes

So I was wondering if I have strings like this:

“hi my name is Sara” “Hello dog” “hi name”

Then how would I get an output where it looks like:

“Hello dog”(since it has a H and is capital letter) “hi my name is Sara” “hi name” (since n comes after m)

I can’t seem to figure this out as the sort() function cannot work with this as I don’t want it to sort individually but as strings.


r/pythonhelp • • Nov 25 '21

I am having trouble with this code:

2 Upvotes

import random

random number pick

npx = random.randint(-9,9) npy = random.randint(9,18)

random

rx = random.randint(-9,9) ry = random.randint(9,18)

bot

x = -9 y = 18

system

while True:

#chexk if y is less thn x
if npy >= npx:
    npy = random.randint(0,18)
elif ry >= x:
    ry = random.randint(0,18)    
elif y >= x:
    y = random.randint(0,18)
    
#random number is found and another number is picked  
r = random.randint(rx,ry)
number_pick = random.randint(npx,npy)

#bot guesses the number    
bot = random.randint(x,y)

#print
print('    for R the number was',r)
print('    for NP was',number_pick)
print('    bot guess',bot)
print('')

#check if bot was correct
if bot == r and bot == number_pick:
    print('        corect guess')
    break
if bot != r  and bot != number_pick:
    print('        incorect')
    chooice = random.randint(0,4)
    
    #randomizing the numbers
    if chooice == 0:
        npy -= 1
        ry -= 1
        y -= 1
    elif chooice == 1:
        npy += 1
        ry += 1
        y += 1
    elif chooice == 2:
        npx -= 1
        rx -= 1
        x -= 1
    elif chooice == 3:
         npy += 1
         ry += 1
         x += 1
    else:
        pass
 
#endintion              
print('')

It's giving this error:

Traceback (most recent call last): File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 31, in <module> start(fakepyfile,mainpyfile) File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 30, in start exec(open(mainpyfile).read(), main.dict) File "<string>", line 22, in <module> File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/random.py", line 316, in randrange raise ValueError("empty range for randrange() (%d, %d, %d)" % (istart, istop, width)) ValueError: empty range for randrange() (8, 5, -3)

[Program finished]


r/pythonhelp • • Oct 26 '21

Please Suggest me a new project that is good for my level.

2 Upvotes

So i recently finished this project in python that makes a graph when you enter a quadratic equation. I used pyturtle to make it. I cant show it because i dont have github (is that bad?).So i wanted to ask for some project ideas that match my level.I know stuff till making basic object and classes.I tried making a discord bot by found myself copy pasting code instead of understanding so i dropped it. I feel that if i see tutorial it isnt my own project cuz the quadratic equation graph i made was made purely by me i didnt google anywhere how to make a graph in python or anything like that


r/pythonhelp • • Oct 16 '21

Can't Read from Serial - PermissionError(13, 'Access is denied.', None, 5)

2 Upvotes

Hello!

I'm using the below code to read serial data being transferred by a MicroBit, save it to a dictionary and apply that information to a function. For the entire span of time that I've been using this code, the connection has worked fine. Unfortunately, for no apparent reason at all, it's been returning the error in the title.

The port works fine and the MicroBit is functioning.

serialPort = serial.Serial(port="COM3", baudrate=115200, bytesize=8, timeout=2, stopbits=serial.STOPBITS_ONE)
serialString = ""

def backgroundSerial():
    name = multiprocessing.current_process().name
    serial_count = 0
    while True:
        if (serialPort.in_waiting > 0):
            serialString = serialPort.readline()
            reading = serialString.decode('Ascii')
            reading = reading.strip('\r\n')
            reading = reading.strip()
            reading = reading.strip('voltage:')
            reading = int(float(reading))
            serial_count += 1
            voltage_dic[serial_count] = reading
            print(voltage_dic)
            checkVoltage(voltage_dic, serial_count)
            time.sleep(1)
            return checkVoltage, voltage_dic

if __name__ == '__main__':
    procname = multiprocessing.Process(target=backgroundSerial, name="proc 1")
    procname.daemon = True
    procname.start()

def checkVoltage(voltage_dic, serial_count):
    if serial_count > 1:
        serial_count_old = serial_count - 1
        previous_value = voltage_dic.get(serial_count_old)
        current_value = voltage_dic.get(serial_count)
        previous_value = int(previous_value)
        current_value = int(current_value)
        voltage_compare = previous_value - current_value
        voltage_compare = int(voltage_compare)
        if voltage_compare > 8:
            print('good to go')
            return True
        else:
            return False
    else:
        return False

Any help that you guys might be able to provide would be massively appreciated.


r/pythonhelp • • Oct 14 '21

trying to make a coinbase bot

2 Upvotes

good morning everyone, I am new to python and coding in general and decided that I want to make a coinbase bot for my first project(I know its kinda a tall order), so far I have been able to pull the price from coinbase plus all other data and can see the price in consol and the .txt file but I am currently stuck on trying to export the information to an excel sheet.

my current code allows me to pull selected crypto info to the console, then redirects it to a .txt file, so that I can extract it, but every time that I try and pull the information from the .txt all I get is -

trade_id

price

size

time

bid

ask

volume

but when I look at the .txt file I can clearly see that the current price is also their

if I could call upon you guys to assist me I would be greatly appreciated in this endeavor of mine

my current code

----

import cbpro

import sys

public = ----

passphrase = ---

secret = ----

auth_client = cbpro.AuthenticatedClient(public, secret, passphrase)

stdout_fileno = sys.stdout

sys.stdout = open("test.txt", "w")

public_client = cbpro.PublicClient()

result = public_client.get_product_ticker(product_id="BTC-USD")print(result)

for ip in result:

sys.stdout.write(ip + "\n")

stdout_fileno.write(ip + '\n')

sys.stdout.close()

----

this is a picture of the .txt file and what it looks like after running the code

the top line of the .txt is the information pulled from coinbase:

{'trade_id': 221192520, 'price': '57996.08', 'size': '0.00199445', 'time': '2021-10-14T19:00:19.723534Z', 'bid': '57990.22', 'ask': '57996.56', 'volume': '13242.84761033'}

the next 7 lines are:

trade_id

price

size

time

bid

ask

volume

when using sys.stdout to pull the information from the print(result) command and import it into a text file I can see the results of print(result) but when trying to extract the data I'm unable to have the numbers

I would like to note that my end goal for this part is to export to excel but since i have yet to figure out how to extract the information i have not added any code to transfer it to excel


r/pythonhelp • • Oct 12 '21

Unable to get past first bit of Jeopardy! parser

2 Upvotes

Hello,

Relatively new to programming in general and very new to Python. I've been working with this Jeopardy parser to parse a bunch of html files into CSVs. I want to make my own Jeopardy clue database for both Python/DB practice as well as Jeopardy practice. It's a win-win!

Prior to this, I was able to use the download script to successfully download ~8000 html files. I have them stored in a folder called "j-archive archive" which is what the parser script is referencing.

However, when I run the parser, all it does is print "Using 8 threads" and then brings up a new command line, and nothing seems to happen in my folders - no CSVs, no nothing. Seems like it just stopping here. How can I move forward? I have tried a few things and was able to move past this point to some extent, but then it tells me that 'main' isn't defined.

from __future__ import print_function
from bs4 import BeautifulSoup
import time
import lxml
import sys
import os
import re
import csv
import progressbar
import concurrent.futures as futures

# Break up CSVs into seasons

CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
SITE_FOLDER = os.path.join(CURRENT_DIR, "j-archive archive")
SAVE_FOLDER = os.path.join(CURRENT_DIR, "j-archive-csv")
NUM_THREADS = 2
try:
	import multiprocessing
	NUM_THREADS = multiprocessing.cpu_count() * 2
	print('Using {} threads'.format(NUM_THREADS))
except (ImportError, NotImplementedError):
	pass

For more context, I believe this was written in Python 2 but I'm running 3.

I really appreciate any help. Happy to provide more details.


r/pythonhelp • • Oct 04 '21

Super easy 2 minute question but I'm new to python coming over from c# and c++ and none of this makes sense, what the heck is wrong with this? I'm trying to get N to lead to ending the loop as well as any response that isn't Y, thanks.

2 Upvotes

isPlaying = True
while isPlaying:
answer = input("Do you want to keep playing?")
if answer == "Y":
print("Okay")
elif answer == "N":
print("Goodbye")
isPlaying = False
else:
isPlaying = False


r/pythonhelp • • Sep 17 '21

Is there a way to run your code?

2 Upvotes

If you made a project on Python and you want to be able to run the code on another electric without installing Python what would be the best way of doing that? Duse it have to be a game or can it be just raw code that you can run?


r/pythonhelp • • Sep 15 '21

HOMEWORK I was trying to write a code which finds the dual numbers and sum them, but I am getting "TypeError: 'int' object is not iterable" . I've been inpecting the code for hours but could not find the problem. Help me out please.

2 Upvotes
from functools import reduce

liste = [1,2,3,4,5,6,7,8,9,10]

def cift_mi(a):
    if (a % 2 == 0):
        return True
    return False

ciftler = (list(filter(cift_mi,liste)))

def toplama(a,b):
    return a + b

sonuc=(list(reduce(toplama,ciftler)))

print(sonuc)

r/pythonhelp • • Aug 25 '21

Openpyxl and Pandas - pulling data from excel files

2 Upvotes

Hey guys, I am a fairly new python user and am trying to learn new modules for working with excel workbooks and sheets. I am trying to use openpyxl, xlsxwriter and pandas to take some password protected excel documents and pull specific data from cells and then have that spit out into a "Master Output" document that the script also creates.

So my workflow would be [Multiple excel workbooks in a directory] -> [Python would create a new workbook] -> [Specific cells from the workbooks would be copied to the new workbook then the new workbook is saved]

I have been able to read the filenames in a list using glob and also writing the data from the old excel sheets to a new one using xlsxwriter, but I am having trouble connecting all the different parts.

Any help with how to get all the smaller parts connected into one would be great!


r/pythonhelp • • Aug 20 '21

Can you help me with my function?

Post image
2 Upvotes