I want to reduce a string what is like for ex.

user input = uw1hsdb6rtona7suid2gtopnewsurbth3dicb8sdherthj9nacse4dr0tondsi5fghethn len=70 chars

the output to be first 4 & the last 4, and between them "..." python output = uw1h...ethn

I was trying so many alternatives but because I am new in field I cannot find the solution :(


On Python strings you can use slice syntax, like input_string[:4]+"..."+input_string[-4:]

  • thank you very much kind regards,
    – alex
    Nov 29 '17 at 10:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .