3 examples of 'how to remove parts of a string in python' in Python

Every line of 'how to remove parts of a string in python' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
1def remove(s):
2 i = 0
3 j = 0
4
5 while i < len(s):
6 if s[i] == 0:
7 i+=1
8 else:
9 s[j] = s[i]
10 i+=1
11 j+=1
12
13 while j < len(s):
14 s[j] = 0
15 j+=1
16
17 return s
32def remove_str_part(istr,start_mark, end_mark):
33 start = istr.find(start_mark)
34 end = istr.find(end_mark)
35 if start != -1 and end != -1:
36 remove_part = istr[start:end+1]
37 istr = istr.replace(remove_part,'')
38 return istr
139def remove_spaces(string):
140 "Elimina los espacios innecesarios de una fila de tabla."
141 return re.sub("\s\s+", " ", string)

Related snippets