Hi Praveen
I am still new to the language but here is what I would do. Sorry I can't
comment on how to best check for efficiency.
my_str='google'
split_by= 2
[ my_str[i:i+split_by] for i in range(0, len(my_str), split_by) ]
Just using a list comprehension.
best,
-Abhi
On Thu, Oct 27, 2011
On 2011/10/28 07:38 AM, Praveen Singh wrote:
splitWord('google', 2)
['go', 'og', 'le']
splitWord('google', 3)
['goo', 'gle']
splitWord('apple', 1)
['a', 'p', 'p', 'l', 'e']
splitWord('apple', 4)
['appl', 'e']
def splitWord(word,
.
Thanks Christian for your links and code
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription
options:http://mail.python.org/mailman/listinfo/tutor
Below [1] is how I would write it, which is simply a
On 10/28/2011 01:38 AM, Praveen Singh wrote:
splitWord('google', 2)
['go', 'og', 'le']
splitWord('google', 3)
['goo', 'gle']
splitWord('apple', 1)
['a', 'p', 'p', 'l', 'e']
splitWord('apple', 4)
['appl', 'e']
def splitWord(word, number):
splitWord('google', 2)
['go', 'og', 'le']
splitWord('google', 3)
['goo', 'gle']
splitWord('apple', 1)
['a', 'p', 'p', 'l', 'e']
splitWord('apple', 4)
['appl', 'e']
def splitWord(word, number):
length=len(word)
list1=[]
x=0