| | |
Splitting a message up into two
![]() |
•
•
Join Date: Nov 2008
Posts: 58
Reputation:
Solved Threads: 0
I am trying to spilt a message in two, if the number of characters is greater that 600, so that each message has no more than 600 characters.
How can i do this
i know how to get the message length
but i am not sure od how to split it.
How can i do this
i know how to get the message length
Python Syntax (Toggle Plain Text)
Message = "sdkfhdslkfhdskfhsdlfjsdlk" print len(Message)
but i am not sure od how to split it.
python Syntax (Toggle Plain Text)
pieces = [] while len(message) > 600: pieces.append(message[:600]) # slice from the start up to (but not including) the 600th character. message= message[600:] #slice from the 600th character to the end. pieces.append(message)
That should split the string up into pieces that are 600 characters long or less. The pieces are stored in the list 'pieces'.
Last edited by scru; Feb 25th, 2009 at 1:18 pm.
![]() |
Similar Threads
- Getting Error Message, during compile process (C++)
- HELP linking header files... undefined error message in g++ (C++)
- Returns null pointer (C++)
- The Definitive Guide to which Forum Software Information (Growing an Online Community)
- Data consolidation across an array a.k.a. Hashed to death... heeelp... (Perl)
- How would I make a tile map, that is easily alterable? (Python)
- Zend PHP Certification (PHP)
- Need help with DirectX code (C)
Other Threads in the Python Forum
- Previous Thread: pygtk: Disable buttons, Comboboxes, checkboxes...
- Next Thread: Printing In Python
| Thread Tools | Search this Thread |
abrupt accessdenied anti apache application approximation argv array beginner book builtin calculator change converter countpasswordentry curved dan08 dictionaries dictionary dynamic edit enter examples file float format function gui heads homework import inches input java keyboard lapse launcher library line lines linux list lists loop microphone mouse movingimageswithpygame mysqlquery newb number numbers numeric output parameters parsing path phonebook plugin port prime programming projects py2exe pygame pyopengl python random recursion redirect remote reverse scrolledtext session simple software sprite statictext string strings syntax table terminal text textarea thread threading time tlapse trick tuple tutorial twoup ubuntu unicode unit urllib urllib2 variable wordgame wxpython






