Python Last Character from String

Python Last Character from String

Print last character from String in python

example:
name=”pramod” 
pramod is a string and in this string there are 6 characters ‘p’,’r’,’a’,’m’,’o’,’d’ 
now we have to print last character that is “d” 
source code
def name(first_name):
return first_name[-1]
first_name=input("enter your first name")
print(name(first_name))

Python Last Character from String

Leave a Comment

Your email address will not be published. Required fields are marked *