Skip to main content

All Questions

0 votes
2 answers
50 views

Replace a certain part of the string which matches a pattern in python 2.7 and save in the same file

I am trying to achieve something of this sort My input file has this kind of entries art.range.field = 100 art.net.cap = 200 art.net.ht = 1000 art.net.dep = 8000 I am trying to match the pattern like ...
Saswata Kar's user avatar
0 votes
3 answers
104 views

How to check if a string contains a word?

S0, basically, I wrote a longer program that tests me on tenses in another language. It tests me randomly based on a die rolled. However, the snippet I quoted does not work for some reason. The ...
Her0Her0's user avatar
  • 547
2 votes
2 answers
1k views

How can i check if a string has all characters of a substring? [duplicate]

I need to find if a string has all characters of a substring. So for a 7 char string i want to know if the chars of a 5 char substings are in the string, without repeating letters (if substring has 2 ...
Gundro's user avatar
  • 129
2 votes
2 answers
985 views

Hackerrank `super-functional-strings` terminates due to timeout

Given a string, p, consisting of lowercase letters, compute the summation of function F(p) = [len(p)**distinct(p)]%[10**9 + 7] over all possible distinct substrings of F. As the result is quite large, ...
Mansour Zayer's user avatar
-4 votes
1 answer
37 views

Getting a list of strings after a start string [closed]

I'm building a Reddit bot that Replies with a link to the app that the redditor specified What I want to achieve is that the user comments with this text ilink: someapp, anotherapp I have no ...
AbdAlWahab Fanr's user avatar
0 votes
3 answers
275 views

Python: How to check for specific characters inside a string from another string [duplicate]

I am coding a simple program in which I would like to have the user input a string and then my code will check from another string of characters (that are not allowed in the string). The string of ...
Alex Galpin's user avatar
3 votes
3 answers
6k views

Extracting a substring from a string in python based on Delimiter

I have an input string like:- a=1|b=2|c=3|d=4|e=5 and so on... What I would like to do is extract d=4 part from a very long string of similar pattern.Is there any way to get a substring based on ...
Mayank Jha's user avatar
  • 1,029
1 vote
2 answers
211 views

Boolean evaluation of a string without conditionals

I'm trying to figure out the solution to this particular challenge and so far I'm stumped. Basically, what I'm looking to do is: Check if substring false exists in string s If false exists in s, ...
Jam's user avatar
  • 31
0 votes
1 answer
44 views

Return number of alphabetical substrings within input string

I'm trying to generate code to return the number of substrings within an input that are in sequential alphabetical order. i.e. Input: 'abccbaabccba' Output: 2 alphabet = 'abcdefghijklmnopqrstuvwxyz'...
maxcopeland's user avatar
-4 votes
3 answers
10k views

.find() function in python isn't working

I've just written this to test out the .find() function in python 2.7 but it doesn't seem to work. My syntax looks right but i cant figure out why it's not working. s=raw_input('Please state two ...
user3092467's user avatar
4 votes
4 answers
371 views

Return string that is not a substring of other strings - is it possible in time less than O(n^2)?

You are given an array of strings. you have to return only those strings that are not sub strings of other strings in the array. Input - ['abc','abcd','ab','def','efgd']. Output should be - 'abcd' and ...
Jit's user avatar
  • 643
3 votes
3 answers
4k views

Check if a string contains all words of another string in the same order python?

I want to check if a string contains all of the substring's words and retains their order; at the moment I am using the following code; However it is very basic, seems inefficient and likely there is ...
temo's user avatar
  • 363
1 vote
2 answers
93 views

Find a substring within a textfile in Python

So I am trying to extract a link within a textfile in Python -- this link varies from textfile to textfile but has the same format. I tried using the re library but keep getting errors. The syntax ...
askannarnia's user avatar
47 votes
5 answers
177k views

Python best way to remove char from string by index [duplicate]

I'm removing an char from string like this: S = "abcd" Index=1 #index of string to remove ListS = list(S) ListS.pop(Index) S = "".join(ListS) print S #"acd" I'm sure that this is not the best way to ...
Alvaro Silvino's user avatar
1 vote
3 answers
1k views

How return substring of url path in Python?

I have this url www.testing.com/drive/rayon.productlist.pagination.topage/2?t:ac=3686975/4441810 and i want to have 2 i tried this in python 2.7: s = 'www.testing.com/drive/rayon.productlist....
parik's user avatar
  • 2,415

15 30 50 per page
X