Tagged Questions
-2
votes
2answers
33 views
python - how merge lists of strings to become one
i'm trying to merge two lists of strings in python ,like:
['this','is','list one'] ,['and','list two','combined']
to become one list.
"+" and "join".
doesn't work for me
the original code:
...
1
vote
2answers
59 views
Taking apart strings in Python
So I am making a quick calculator script in Python, and I need to take apart a short string. The program first displays a short welcome message, then a prompt asks What they want to do calculate, and ...
0
votes
4answers
41 views
How can I capture a value from a string and then remove it?
I'm trying to get the number from a string and then remove that number. For instance, I'm going to have a string like '42Xmessage' where 42 is the number I want (it could be any number of digits) and ...
0
votes
2answers
28 views
python string.replace() a string + 12 characters following
I am using python to scrape some info off IMDb and am looking to replace a given text + 12 characters that follow it with a blank. Is this possible? Here is an example:
I have the string
'<a ...
1
vote
1answer
24 views
Appending ten digit integer to list concatenates some entries with an “L”
I wrote a small script to find n-digit primes in the digits of e (in relation to that old Google ad):
import math
# First 251 digits of e
e_digits = ("2"
"7182818284 5904523536 ...
-1
votes
1answer
53 views
python replace records in variable
I have:
x = "abcdefghi", and I want to replace record from that variable with another record.
for example:
x = "abcdefghi"
x.replace(x[1], x[1+2]), and I want to do a such thing to all records in ...
0
votes
2answers
32 views
Appending str onto str
I've been working on a simple Caesar Shift in python, but when I try to run it it says that:
File "Ceaser Shift.py", line 36, in main
ciphertext += shift(letter,shift)
TypeError: 'str' object is not ...
0
votes
3answers
29 views
Add two different values to string from different lists
so i have two different lists of strings; i.e. x and y.
len(y) = len(x) - 1
i want to add them together in an empty string in the original order so basically the output = x1 + y1 + x2 + y2 + x3
...
3
votes
3answers
100 views
__str__ outputs “instance at 0x00E4F558”
This is my first cry for help in this site. I have searched for an answer here, but nothing really clears it for me.
I'm trying to learn Python. I've in the "class" chapter.
The following code:
...
1
vote
4answers
64 views
Determining the most common word from a user's input. [Python]
The way I tried to solve this problem was by entering the words of a user into a list and then using .count() to see how many times the word is in the list. The problem is whenever there is a tie, I ...
0
votes
5answers
56 views
Divide string by line break or period with Python regular expressions
I have a string:
"""Hello. It's good to meet you.
My name is Bob."""
I'm trying to find the best way to split this into a list divided by periods and linebreaks:
["Hello", "It's good to meet you", ...
1
vote
7answers
74 views
What is the easiest but not fastest way to format this string into a list? Python
I want to append rows of digits in the form of one long string to be appended to a list inside of a list based upon their row. For example, I know ahead of time that each row has 4 digits that can ...
1
vote
1answer
23 views
How to convert 'binary string' to normal string in Python3?
For example, I have a string like this(return value of subprocess.check_output):
>>> b'a string'
b'a string'
Whatever I did to it, it is always printed with the annoying b' before the ...
3
votes
3answers
107 views
Removes spaces from a string
I can't, and I can't figure out what's wrong. The lists I'm trying to strip of spaces are like this:
['L500', ' ', '622651 ', '2007', ' 452295.00', ' 7420', ' 0']
but with spaces ...
0
votes
1answer
31 views
Hashing strings for load balancing
There's a great deal of information I can find on hashing strings for obfuscation or lookup tables, where collision avoidance is a primary concern. I'm trying to put together a hashing function for ...
2
votes
2answers
44 views
Extract specific values from string
I want to extract all words that have the following label "w=". Example, I will need, " THAT HAVE RECEIVED NO" from the string below.
w="THAT" v="22.23092" a="19.09109" i="3"/>
<r s="1480150" ...
-1
votes
3answers
31 views
Need to extract substring in python with regex
I have a string
('some text', [], ['IP address'])
I want to extract only the 'some text' part from this whole string.
I have no experience with regular expressions, which is needed here.
-1
votes
1answer
28 views
Python String index out of range [BBP Hexideximal]
I am aware of all the questions asked about this error, but couldn't find one that fitted my problem.
My goal was to take this code:
def pi():
N = 0
n, d = 0, 1
while True:
xn = ...
0
votes
2answers
26 views
Seperate one part list into four part list with Python
The program I've created prints out the list:
['2 19 2839475239874 hda']
It was supposed to look like this:
['2','19','2839475239874','hda']
So instead of having a list with four parts to ...
0
votes
2answers
34 views
Extracting a changeable string from a list and insertion in Python
I'm still learning Python, so bare with me!
I have a list that looks like this:
['2 19 2839475239874 hda']
I need to extract the hda from the end. However, the hda may not always be the last ...
0
votes
1answer
30 views
String to float and regex
I have a problem with regex and my string...
I need a solution in my regex code for take a float number of a string. I don't know why this code doesn't work.
from bs4 import BeautifulSoup
import ...
0
votes
2answers
39 views
How do I format a string within a function call?
I want to pass a string to a variable to a string, which in turn gets passwd onto a function. I had written the code below:
Not Working
env = 'D'
myFunction("Checking Processes A%s/B%s",'')% ...
0
votes
0answers
26 views
struct.error: unpack requires a string argument of length 2
I have this following code it works 64bit another computer but it does not work with mine and gives the fallowing error.I use Python 3.3 and the requiered libraries. I could not solve the problem ...
2
votes
2answers
28 views
Extracting string based on 2 lists of integers. Python
seq = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
start = [2,9,18]
end = [6,12,20]
#output = seq[end[k]:start[k+1]]
i'm trying to the sequence between end[k] and start[k+1] #seq[end[k]:start[k+1]]
so there ...
1
vote
4answers
33 views
Convert range(r) to list of strings of length 2 in python
I just want to change a list (that I make using range(r)) to a list of strings, but if the length of the string is 1, tack a 0 on the front.
I know how to turn the list into strings using
ranger= ...
0
votes
5answers
69 views
How do you split a string into quoted sentence and numbers using python
Hi guys I am new to python and would appreciate some help!
I have multiple strings like this:
21357.53 84898.10 Mckenzie Meadows Golf Course 80912.48 84102.38
And I am trying to figure out how to ...
1
vote
2answers
28 views
Find and cut out a python substring
Here is what I'm trying to do:
I have a long string:
s = asdf23rlkasdfidsiwanttocutthisoutsadlkljasdfhvaildufhblkajsdhf
I want to cut out the substring: iwanttocutthisout
I will be iterating ...
0
votes
0answers
23 views
Getting a list of references using cscope and python
I am writing a Python script to edit a large C project. In this script I am using the subprocess module to call cscope's line oriented interface. This is an example of what I have been doing...
...
2
votes
1answer
60 views
python - fastest way to compare lists and search for term in list
Right now I'm writing some python code that needs to make list comparisons similar to the following:
small_list = ["string"]*3
big_list = ["string"]*600000
big_list_excludes = ["string"]*600000
...
0
votes
2answers
47 views
Trying to parse a string into a list in Python
So I have a string like so:
pattern = "AAaa$$##"
I want to parse it into a list so it outputs letter by letter,
but I can't do pattern.split("") cause it gives an error.
Like this pattern.split() ...