Search code examples
pythonstringtkinterstring-length

Is there a way to get the length, last character, and last two characters of an input from Tkinter (Entry function)?


I'm using the Tkinter Entry function, and need to know if there is a way to get the length, last character, and last two characters of the input.


Solution

  • The simplest solution is to get the value, and perform string operations on the value:

    value = the_entry.get()
    length = len(value)
    last_char = value[-1]
    last_two = value[-2:]