Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to remove first few characters from string in python

a_string = "abcde"

sliced = a_string[2:]
Remove first 2 characters

print(sliced)
Comment

python string cut first n characters

# 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 :: python string cut right 
Python :: os path splitext 
Python :: series.string.split expand 
Python :: python 3.11 release date 
Python :: python turtle fill 
Python :: python property decorator 
Python :: python serial readline 
Python :: get file size python 
Python :: import turtle as t 
Python :: neural network hyperparameter tuning 
Python :: run python script from repl 
Python :: get a column of a csv python 
Python :: sentence similarity python 
Python :: how to type using selenium python 
Python :: seaborn plot histogram for all columns 
Python :: Bar Charts bokeh 
Python :: captions overlap in seaborn plot jupyter 
Python :: tkinter toplevel 
Python :: pandas groupby largest value 
Python :: python tkinter entry widget 
Python :: creating dataframe 
Python :: np.eye 
Python :: bokeh xlabel rotate 
Python :: python append list 
Python :: check for prime in python 
Python :: django orm group by month and year 
Python :: pygame collisions 
Python :: create login system in python 
Python :: pyaduio linux 
Python :: pytorch mse mae 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =