Python Forum
How to split a String from Text Input into 40 char chunks?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to split a String from Text Input into 40 char chunks?
#1
Sad 
Hi all.

I Need a Solution split String a String into 40 char chunks.

The String is from a User Input and can be longer (between 1 and 290 Chars), but i Need to Split the String into max 40 char packets which will be padded by spaces to have a readable resulting text.

My First Idea was to Split the whole string by spaces as delimiter and rebuild the new 40 char Packs by Looping over the Split result. But question is, isnt there a smarter way to solve that ?
Reply


Messages In This Thread
How to split a String from Text Input into 40 char chunks? - by lastyle - Jul-31-2023, 06:58 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Get the string after a specific char JanJan 5 448 Apr-30-2025, 05:04 AM
Last Post: snl_9527
  Unable to understand the function string.split() Hudjefa 8 2,672 Sep-16-2024, 04:25 AM
Last Post: Pedroski55
  Using string input for boolean tronic72 3 2,061 Nov-01-2023, 07:48 AM
Last Post: Gribouillis
  doing string split with 2 or more split characters Skaperen 22 6,440 Aug-13-2023, 01:57 AM
Last Post: Skaperen
  [split] Parse Nested JSON String in Python mmm07 4 2,827 Mar-28-2023, 06:07 PM
Last Post: snippsat
Question Take user input and split files using 7z in python askfriends 2 2,381 Dec-11-2022, 07:39 PM
Last Post: snippsat
  How to split the input taken from user into a single character? mHosseinDS86 3 2,200 Aug-17-2022, 12:43 PM
Last Post: Pedroski55
  is there an itertor of chunks? Skaperen 8 3,630 Jul-22-2022, 10:17 PM
Last Post: Skaperen
  Split string using variable found in a list japo85 2 2,200 Jul-11-2022, 08:52 AM
Last Post: japo85
  Editing text between two string from different lines Paqqno 1 1,858 Apr-06-2022, 10:34 PM
Last Post: BashBedlam

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020