Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python string cut substring

text = "Hello World!"
x = text.replace("World", "")
print(x)

>>> Hello !
Comment

python string cut left

# string [start:end:step]
string = "freeCodeCamp"
print(string[0:len(string)-1])		# freeCodeCam
print(string[0:5])		            # freeC
print(string[2:6])		            # eeCo
print(string[-1])		            # p
print(string[-5:])		            # eCamp
print(string[1:-4])                 # reeCode
print(string[-5:-2])	            # eCa
print(string[::2])		            # feCdCm
Comment

PREVIOUS NEXT
Code Example
Python :: finding the maximum value in a list python 
Python :: python mathematics 
Python :: python raise exception 
Python :: code to take the picture 
Python :: pandas convert string column to int list column 
Python :: python for loop with step 
Python :: python save button 
Python :: remove part of string python 
Python :: split a string into an array of words in python 
Python :: binary to string python 
Python :: how to iterate over a list in python 
Python :: if-else 
Python :: python dictionary multiple same keys 
Python :: inherit init method 
Python :: python datetime greater than now 
Python :: TypeError: Can only append a dict if ignore_index=True 
Python :: fibonacci number 
Python :: try python 
Python :: numpy linspace of dates 
Python :: iterate through directories in python 
Python :: res.send is not a function 
Python :: flask start development server 
Python :: floating point python 
Python :: python delete first two indexes 
Python :: get url param in get django rest 
Python :: dataframe subtract value from previous row 
Python :: getsizeof python 
Python :: print list in one line 
Python :: what does % do in python 
Python :: pytorch calculate mse mae 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =