Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python string cut to length

# 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 :: os path splitext 
Python :: python count of letters in string 
Python :: flask session timeout 
Python :: python two string equal 
Python :: python delete all occurrences from list 
Python :: Python "for in" loop to print the last item in the list 
Python :: password guessing game python 
Python :: Filter with List Comprehension 
Python :: pillow image from array 
Python :: telegram bot webhook python 
Python :: arg parse array argument 
Python :: python delete directory contents 
Python :: create numpy array with ones 
Python :: double variable for loop python 
Python :: days in month function python 
Python :: How to calculate distance without numpy 
Python :: write list to csv python 
Python :: size pandas dataframe 
Python :: remove brases from array py 
Python :: Get the square root of a number in Python 
Python :: python switch statement 
Python :: pygame.events 
Python :: pandas filter rows by value 
Python :: sys.maxsize in python 
Python :: rolling window pandas 
Python :: split pdf python 
Python :: pandas difference between rows in a column 
Python :: remove decimal python 
Python :: django media url 
Python :: image resize in python 
ADD CONTENT
Topic
Content
Source link
Name
6+4 =