samedi 26 janvier 2019

How to be able to add a character at a certain string length(Python)?

I'm working on an input system with Tkinter. I need a new line to appear on the 23rd character, without destroying any previous text.

The user will input text well over 20 characters, which after 23 characters a line needs to be added. After the 23rd character the rest of the text should show up under that in the same Tkinter Label box. Thank you!!

len_user_input = len(user_input)
if len_user_input > 23:
    #i have tried this but didn't work how I needed it to but I 
     #may be using it wrong '''
     new = len_user_input[:23] + '\n' + ;en_user_input[2:]

Aucun commentaire:

Enregistrer un commentaire