In: Computer Science
Given a String variable named sentence that has been initialized, write an expression whose value is the the very last character in the String referred to by sentence.
write it in python
The following information has been provided for the question above:
NOTE: Code indentation is very important for python code execution. I used Python.3.5.1 IDE to run this program.
Screen shot of python code:
Output:
Text format code:
#Initialized a string variable named sentence
sentence="Test"
#An expression whose value is the the very
#last character in the String referred to
#by sentence
lastChar=sentence[len(sentence)-1]
#Display output
print("Initialized sentence is: ", sentence)
print("Very last character in the sentence is:
",lastChar)