I would like to loop over a file where there is an date index and values. Looping backward would help to prevent checking a date where there is no data. So it should stop as it find the first date. I set a today date, change into the appropriate format that correspond to the date in the file, try to
TKinter doesnt execute command based on answer
Introduction Im making custom Dialogue usign TKinter Templates. somewhere’s in the script, there’s MessageBox so users can determine wether its should aborted or continued. Here’s the code : import …
Saving a new list from a a larger list using a loop
I have a large list, which I am pulling out every nth value from the first value up to the mth value to create new lists and I am using a for loop. My question is, how do I create a new list variable each time through the for loop? By way of simple example, I have the list: Which
Search word in word documents and print out the file name that contains that word?
Hey so I am new to Python and I wanted to make a script that retrieves the file name from a list of docx documents in a large directory if a file contains a certain word inside the word document. Here is my code below so far My thought process is to convert all these docx documents to txt files
How do I get a list of all the roles my discord bot has?
I am trying to get a list of all the roles my bot has from top to bottom so I can get the highest role’s color. Answer Not sure what you mean by the “highest role’s color”, also your post is missing your code. One way to get the roles the bot has in the guild (via a command) is
emptying JSON file
I want to completely empty a JSON file, while still keeping the file. How do I do that? I tried: , etc but none of them work. Please help me out! Ive seen answers on how to delete keys in the JSON, or delete the entire file, but not how to just replace it with nothing. Answer You can just
Python change Exception printable output, eg overload __builtins__
I am searching for a way to change the printable output of an Exception to a silly message in order to learn more about python internals (and mess with a friend ;), so far without success. Consider the following code The code shall output name ‘x’ is not defined I would like the change that output…
Pandas add missing weeks from range to dataframe
I am computing a DataFrame with weekly amounts and now I need to fill it with missing weeks from a provided date range. This is how I’m generating the dataframe with the weekly amounts: Which outputs: If a date range is given as start=’2020-08-30′ and end=’2020-10-30′, then I wou…
Take the contents of a tag without taking the contents of its child in web scraping using python
I am scraping data from a newspaper website using beautifulsoup. I am trying to take the news articles and storing them in lists. But there are ad slots in between article paragraphs. I want to take the paragraphs but leave the ad content. I thought of using a condition that will take the content only if its …
Creating multiple graphs using gnp_random_graph
While using the NetworkX package I was tasked with creating multiple random graphs with a given n number of nodes and p probability, this is my code: But, every iteration creates the same exact graph (even the edges are completely the same) Does anyone have a clue what might be wrong? Update: After trying to …