Answer:
Expression for 1st option:
last_character=name[len(name)-1]
print(last_character)
Expression for 2rd option:
length_of_the_string=len(sentence)
print(length_of_the_string)
or
length=0
for x in sentence:
length=length+1
print(length)
Expression for 3rd option:
last_character=name[len(name)-1]
print(last_character)
Step-by-step explanation:
- The first and the third questions option are same, so the answer to those options are also the same.
- The len function is used in python which is used to find the length of the string.
- The user can also find the string length by the help second option which is written in option 2 answers. It uses a for loop which scans the character and counts the length.
- The len function defines the length and if any user needs to print the last character then he can do it with the help of string size -1.
- It is because the string is a collection of character array which index starts from 0 and ends in size-1.