Questions tagged [python]

Python is an interpreted, general-purpose high-level programming language whose design philosophy emphasizes code readability. Use the python tag for all Python related questions. If you believe your question may be even more specific, you can include a version specific tag such as python-3.x.

Filter by
Sorted by
Tagged with
5 votes
1 answer
209 views

Simulation of hero vs monster

I fairly started coding no more than 2 weeks now; not even for long, and a thread inspired me to make a random back-to-forth game between a Hero and a Monster where it randomly choose a certain number ...
3 votes
1 answer
42 views

Generating indent and dedent tokens for python-style indenting code

I found lexy, a C++ template-based parser combinator, that helps a lot to build a language parser. The problem is that lexy can only deal with context free grammar, and python indentation is not ...
  • 293
0 votes
1 answer
65 views

Efficient way to read files python - 10 folders with 100k txt files in each one

i am looking for an efficient way to read and append texts of .txt files to a dataframe. I currently have 10 folders with 100k documents each. What i specifically need to do is: getting the names of ...
1 vote
1 answer
40 views

Calculate result of an election using the D'Hondt method

I have learned about list comprehensions a week or so ago and understood that they can save a lot of screen space. Though, I have been told that this is bad practice only to use them, even if it ...
0 votes
0 answers
22 views

Checking several strings against a n-depth list of lists and returning one if its values

The data structure I am working with is a list of lists that is created by parsing a file. The depth of the list can vary. The list can have n Strings before its child-value begins. My current example ...
  • 151
1 vote
1 answer
56 views

Simple text-game navigation system

I am a total newbie when it comes to coding in general, let alone Python. After following a few tutorials, I decided to try making my own little navigation system for simple maps, sort of drawing from ...
0 votes
1 answer
60 views

Permutations CodeWars problem solved!

i have solved a question in codewars: https://www.codewars.com/kata/5254ca2719453dcc0b00027d/python , here's my solution is it unefficient to use itertools because people are blaming that is cheating ...
  • 111
3 votes
3 answers
520 views

Extract section from URL path

Any comments / improvements welcome on this simple function. tests.py ...
  • 353
8 votes
3 answers
455 views

Python+R Project: Fantasy Football Power Rankings Graphic Generator

I am in a fantasy football league and each week I send out a power rankings poll through Microsoft Forms. People will send in their rankings poll and I will create a graphic based on responses. I was ...
3 votes
1 answer
36 views

SImple Inverted Index

This is a simple inverted index I made. The goal is to: Read set of text files from a directory, docs Tokenize them Normalize the tokens by removing punctuation ...
1 vote
1 answer
32 views

Make unique id based on text data column with similarity scoring

I have the following dataframe: ...
0 votes
1 answer
43 views

Produce a squence of even integers beginning at a given number

I'm learning python and I have the following prompt. I am trying to implement a function that: is named even, takes 2 integer arguments, start and n, and returns a list of n smallest even integers ...
  • 11
0 votes
0 answers
24 views

Short Text Pre-processing

For educational purpose I am preprocessing multiple short texts containing the description of the symptoms of cars fault. The text is written by humans and is rich in misspelling, capital letters and ...
2 votes
0 answers
31 views

Control your laptop using hand gestures

This program uses webcam to track hand movements / gestures and sends corresponding mouse / keyboard events to the computer. I use it to switch spaces, move active window between desktops, scroll ...
-3 votes
0 answers
33 views

Optimizing code to map a key of dictionary to all elements inside the list as values [closed]

I have a query: i have a input1 in below code format where input1 is dictionary with keys and its corresponding values in list format, the 3 keys are location, resource_name and type, as you note ...

15 30 50 per page
1
2 3 4 5
1000