string

Create regex-like (run length encoding) of string s for blocks of a given length k

Create regex-like (run length encoding) of string s for blocks of a given length k Question: I am looking for python code to perform a run length encoding to obtain a regex-like summary of a string s, for a known length k for the blocks. How should I tackle this? e.g. s=TATTTTATTTTATTTTATGTTATGTTATGTTATGTTATGTTATGTTATGTTATGTTATGTTACATTATTTTA with k=5 could …

Total answers: 4

Longest Repeating Subsequence: Edge Cases

Longest Repeating Subsequence: Edge Cases Question: Problem While solving the Longest Repeating Subsequence problem using bottom-up dynamic programming, I started running into an edge case whenever a letter was repeated an odd number of times. The goal is to find the longest subsequence that occurs twice in the string using elements at different indices. The …

Total answers: 3

Regex string parsing: pattern starts with ; but can end with [;,)%&@]

Regex string parsing: pattern starts with ; but can end with [;,)%&@] Question: I am attempting to parse strings using Regex. The strings look like: Stack;O&verflow;i%s;the;best! I want to parse it to: Stack&verflow%sbest! So when we see a ; remove everything up until we see one of the following characters: [;,)%&@] (or replace with empty …

Total answers: 1

What is the fastest and simplest way to remove "" from a string

What is the fastest and simplest way to remove "" from a string Question: when im parsing a lot of data with python and it can happen that some parts of the data contains strings/chars with , this can lead to problems when working with the data so my goal is minimize errors by removing …

Total answers: 1

Why does Python's rstrip remove more characters than expected?

Why does Python's rstrip remove more characters than expected? Question: According to the docs the function will strip that sequence of chars from the right side of the string. The expression ‘https://odinultra.ai/api’.rstrip(‘/api’) should result in the string ‘https://odinultra.ai’. Instead here is what we get in Python 3: >>> ‘https://odinultra.ai/api’.rstrip(‘/api’) ‘https://odinultra.’ Asked By: Corneliu Maftuleac || …

Total answers: 1

Python comparison problem for wordle type game

Python comparison problem for wordle type game Question: I am making a wordle game in python. For that i need to compare the wordle word(mentioned as random_word in the code) to the input by user. The problem is i am unable to devise a method to handle repititions of letters in any word. Here is …

Total answers: 3

Why is the first string variable from my function being printed out of line?

Why is the first string variable from my function being printed out of line? Question: I’m just a newbie in python and programming in general. And i made this simple hospital python script which prints out a specific patient’s information. The code works just fine. But for some reason the final output gives me some …

Total answers: 1

Python selenium string formatting in web element

Python selenium string formatting in web element Question: How do I iterate over multiple div web elements? I want to collect EPA Registration numbers (ex: 12455-61, 12455-61-3240) using a for loop, but I get error that the web element cannot be located using string formatting. Here’s the HTML: <div class="product"> <div class="mainSection"><p><span class="reportLabel">EPA Registration #:</span> …

Total answers: 2