-1

I'm making a some encryption thing and I want to know a way or module to split a string a same or deferent character parts. For example,

I need to split this example for 5,10,15 likewise characters,

12gbs7%hb#bhBh&BHbG8yVByb8...n

12gbs 7%hb#bhBh &BHbG8yVByb8...n

  • 3
    Does this answer your question? [Python split string into multiple string](https://stackoverflow.com/questions/9703512/python-split-string-into-multiple-string) – John Snow Jun 04 '21 at 22:59

1 Answers1

0
def split_by(string, n):
    return [string[n*i:n*(i+1)] for i in range(len(string)//n+1)]
Larry Panozzo
  • 101
  • 1
  • 6
  • While this code may answer the question, providing additional context regarding why and/or how this code answers the question improves its long-term value. – Thavas Antonio Jun 05 '21 at 00:49