Login or Sign Up
Logging in...
Remember me
Log in
Or
Sign Up
Forgot password or user name?
Log in with
Search in titles only
Search in Python only
Search
Advanced Search
Forums
Product Launch
Updates
Today's Posts
Member List
Calendar
Home
Forum
Topic
Python
very simple string to list function
Collapse
X
Collapse
Posts
Latest Activity
Photos
Page
of
1
Filter
Time
All Time
Today
Last Week
Last Month
Show
All
Discussions only
Photos only
Videos only
Links only
Polls only
Events only
Filtered by:
Clear All
new posts
Previous
template
Next
v13tn1g
New Member
Join Date:
Feb 2009
Posts:
31
#1
very simple string to list function
Mar 16 '09, 06:20 PM
the question that im wondering is how do i split into one list of str, say "123456789" into for every third value
so the output would be ['123' , '456' , '789']
thanks
v13tn1g
New Member
Join Date:
Feb 2009
Posts:
31
#2
Mar 16 '09, 06:42 PM
solved:) the problem
Comment
Post
Cancel
bvdet
Recognized Expert
Specialist
Join Date:
Oct 2006
Posts:
2851
#3
Mar 16 '09, 10:31 PM
I am glad you figured it out. Here's what I was going to suggest:
Code:
>>> s = "123456789" >>> [s[i:i+3] for i in range(0, len(s), 3)] ['123', '456', '789'] >>>
Comment
Post
Cancel
Previous
template
Next
Working...
Yes
No
OK
OK
Cancel
👍
👎
☕
Comment