Answers for "python find beginning and end of string"

18

python get first character of string

string = 'This is a string'
print(string[0])
#output: 'T'
Posted by: Guest on April-18-2020
0

get end of string python

a = "abcde"
lastChar = a[-1]
print(f'Using index, lastChar is {lastChar} , using slice last char = { a[len(a)-1::] } = { a[len(a)-1] } = { a[:-2:-1] }') 
'''
output
Using index, lastChar is e , using slice last char = e 
'''
Posted by: Guest on November-06-2021

Code answers related to "python find beginning and end of string"

Python Answers by Framework

Browse Popular Code Answers by Language