Ask Question
25 May, 18:23

Write a program that prompts the user to enter a string (may contain spaces) and displays its last character. Enter s string: Programming is fun The last character is n

+3
Answers (1)
  1. 25 May, 18:38
    0
    The programming language in Python is as follows:-

    #Prompt user for input string

    userinput = input ("Enter a string: ")

    #Print the last character of the input

    print ("The last character is "+userinput[-1])

    #End of Program

    Explanation:

    This line is a comment

    #Prompt user for input string

    This line prompts user for input

    userinput = input ("Enter a string: ")

    This line is also a comment

    #Print the last character of the input

    This next line prints the last character of the input string; the last character is defined by the index - 1

    print ("The last character is "+userinput[-1])
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Write a program that prompts the user to enter a string (may contain spaces) and displays its last character. Enter s string: Programming ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers