Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

get first x characters of string python

characters = 4
string = "This is a string"
print(string[:characters])
#output: 'This'
Comment

python get first character of string

string = 'This is a string'
print(string[0])
#output: 'T'
Comment

PREVIOUS NEXT
Code Example
Python :: python string replace index 
Python :: convert pdf folder to excell pandas 
Python :: append record in csv 
Python :: python permutation 
Python :: python 3.9 features 
Python :: flask read form data 
Python :: Concatenate strings from several rows using Pandas groupby 
Python :: import django-on-heroku 
Python :: catch error python 
Python :: small factorial codechef solution 
Python :: how to take multiple input in list in python 
Python :: python django shell command 
Python :: python get element from list 
Python :: shutil remove 
Python :: python check if nan 
Python :: converting binary to octal in python 
Python :: max pooling tf keras 
Python :: 2 variables with statement python 
Python :: beautifulsoup remove element 
Python :: python reverse geocode 
Python :: python cut string after character 
Python :: flatten nested list 
Python :: print pandas version python 
Python :: padnas drop column 
Python :: add to number in python 
Python :: plt.imshow not showing image 
Python :: all letters an numbers py array 
Python :: roots of quadratic equation in python 
Python :: count the number of rows in a database table in Django 
Python :: what is imageTk in pil python 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =