All Questions
Tagged with python-3.x string
5,484
questions
0
votes
1
answer
50
views
Unicode strings in a purely python3 codebase - are these useless? [duplicate]
In the codebase that I'm working on, there seems to be remnants of python2 because a lot of the strings are prefixed with u.
From researching, it looks like this denotes a unicode string, but in ...
0
votes
1
answer
45
views
Find a Substring in String with Boardtools is not working if the string contains special chars
Today I got frustrated. I'm implementing a very simple logic with substring finding; it turned out to be a more complex situation.
Let's consider this small python code:
word_one, word_two = ['(/ %$ss%...
-1
votes
2
answers
33
views
Why does the str() not work on filter objects?
besthand = "AAAAJ"
besthand = str(filter("J".__ne__, besthand))
why is the type of besthand still a filter object? I've seen that you can use
besthand = "".join(besthand)...
-2
votes
3
answers
115
views
How can we use Python to extract Arabic words from a string of text? [duplicate]
Suppose that we have a string of text that contains a mixture of English words and Arabic words.
Our goal is to extract the Arabic words and omit or delete all English words.
Input:
The initial Baa’ “...
1
vote
1
answer
73
views
Python 3 process non-printable characters in a unicode string [duplicate]
I'm reading text that contains non-printable characters such as backspaces from a file example.log.
If I'm reading the content of the file in a terminal running cat example.log, I obtain a well ...
0
votes
3
answers
134
views
Multiple substrings in string python within variable check [duplicate]
I have the following code:
check = "red" in string_to_explore
How can I replicate it for multiple substrings?
I tried with:
check = "red|blue" in string_to_explore
but doesn't ...
-2
votes
2
answers
79
views
How to get a single slash in the string?
Image:
I have the following string: 'To reach the peak \\U0001fa77'
It is clear that the last part is the emoji symbol, but it has to slashes before it, so when I print the string, I get 'To reach ...
-2
votes
1
answer
45
views
When I tried to count the string of translated language (tamil) in Python, it didn't give me the correct count why?
code
I tried to count the string for the name 'KUMAR' with length function, output came 5 it is correct.
But when I tried to count the same name in a different language(Tamil) the output I expected ...
0
votes
0
answers
44
views
Regular expression matching variable at end of string
I have some histograms in a .root file which are called "Name/NameEvent1Ch0", "Name/NameEvent1Ch1"... "Name/NameEvent1Ch31" ... "Name/NameEvent2Ch0"... "...
0
votes
0
answers
41
views
Single quotes being swapped for double quotes upon replace
I have a pandas DataFrame that looks like this
orig_id modified_id original_term modified_term
1929 3668340 3578283 Advocate for clients'' needs. Advocate for ...
0
votes
0
answers
32
views
Formatting multiplication tables in python; not how to, just some explanation
I'm meant to make a multiplication table in Python using nested loops. I had trouble formatting it to make a table and looked for answers online. I came across a solution:
uplim=int(input("What ...
0
votes
3
answers
61
views
Print separate word string horizontally
I'm beginner just start learning python and this is really confusing me because i want to test practicing using string.
The output should be like above. The spacing between two columns is one tab.
-1
votes
2
answers
39
views
Looping through string - Adding and skipping characters
I have the below code (which is wrong) and i would like to count the number of times the word "car" appears. So the output here would be 2.
word="cccccccaaaaaaaaaaarrrrrccar"
count=...
1
vote
1
answer
66
views
Get a list of replacement fields from a Python string
I have a string like this:
my_str = '{one}, {two}, {three}'
print(my_str.format(one=1, two=2, three=3)) #1, 2, 3
I would like a list of replacement fields in my string:
get_replacement_fields(my_str) ...
-1
votes
1
answer
45
views
Index out of range error on Leetcode problem no 17
can anyone tell me why i am getting an IndexError in the following code. It doesn't make any sense to me.
class Solution(object):
def letterCombinations(self, digits):
matchnums={
&...