Tagged Questions
0
votes
1answer
14 views
Making a class attribute into a string
I know what the problem is, i just don't know how to fix it. I've googled how to make a class attribute into a string and I can't find anything. I know it's trying to add a class attribute to a string ...
0
votes
3answers
29 views
Recursive function not returning True or False, but flows correctly and works?
Here's how the question's phrased:
Write a recursive function called double letters with a single parameter astr, which is a string. The functin returns True if astr is a string containing “double ...
2
votes
1answer
20 views
How to generate subpeptides (special combinations) from a string representing a cyclic peptide?
Here is my problem: I have a sequence representing a cyclic peptide and I'm trying to create a function that generate all possible subpeptides. A subpeptide is created when bonds between 2 aminoacids ...
0
votes
1answer
37 views
Replacing words in a string- but with two different words: Python3
Trying to get it so that it takes input the same number of times the certain word appears in the original string and replaces it with each word that was the input.
def replace_parts_of_speech ...
0
votes
2answers
21 views
Extract floats from string to create multiple/multidimensional arrays to manipulate data
First off, I am very weak programmer, and new to python and this site. Sorry for my mistakes. So here goes, my data file looks like this:
http://pastebin.com/60E84azv
there are 6221 lines in total ...
0
votes
3answers
76 views
If x is 3 higher than y
I'm doing a program to do a guessing game; I need to be able to make the program give feedback of H or L only if a number is 3 higher than the random number or 3 less.
This is what I currently have
...
0
votes
1answer
26 views
Remove String Literals from Python Strings when writing a File
I am writing some text to file in Python. The problem is that the string literals with extra singles quotes get written to the file. I want to avoid that.
I have a multiple language string which i ...
2
votes
1answer
37 views
Python - Erase the first word in a line in a nested loop
I want to produce the following output:
20 $ 476321.30 $ 923268.18 $ 1859015.31 $ 3840898.15
with this code:
for age in range(20, 70, 5):
for percentage in range(4, 12, 2):
result = ...
3
votes
1answer
41 views
any shorter or faster alternative to bytes(str(some_variable), 'utf-8') in Python 3?
For example, what's the best way to convert an integer like 5638463263 to its "byte stringified" version; b'5638463263'?
I can write bytes(str(5638463263), 'utf-8'), but that seems a bit verbose to ...
0
votes
2answers
49 views
looking through a string for a substring
This code seems to work if I use an alternative string and substring but as soon as a letter appears twice in a row this function flipsout, can someone correct me?
I want it to return True or False, ...
1
vote
5answers
71 views
Getting rid of duplicate blocks in a string
I've got a string broken into pairs of letters and I'm looking for a way to get rid of all the pairs of identical letters, by inserting characters in between them, to form new pairs. Further, I'm ...
-2
votes
2answers
28 views
A map of string replacements in Python2.7
I have file with strings "one", "two", etc for all number representations. I want them to be replaced with actual numbers 1, 2, 3 etc. That is, i want a mapping of {"zero", "one", "two", ..., "nine"} ...
0
votes
0answers
54 views
Strings with slashes & “is” in Python [duplicate]
Just a bizar thing I just noticed in Python. If I use a string in Python, the "is" comparison shows the same result as the "==" comparison:
>>> a = "bc"
>>> a is "bc"
True
...
0
votes
1answer
31 views
Extracting strings in Python in either single or double quotes
I need help with a Python regex to extract strings either inside single or double quoted. I found a solution but the regex is in C# here:
How to extract the string in the quotes (either double quotes ...
2
votes
5answers
40 views
python concatenate substrings by two lists with given start and end positions
Hello to Masters of Python!
As the title says, I have to concatenate substrings with the information provided in two lists of start and end position, respectively.
For example,
string = ...