I have the following problem:
Let's say s = 'ab'. len(s) = 2. it has 2 indexes: 0 and 1. What I want to do is to make ab of length 1, or have an index of 0.
All help is welcome
Thanks
If I understood your question then I guess you're looking for slicing:
>>> s = 'ab'
>>> s = s[:1]
>>> s
'a'
Update:
You need a list to do that.
>>> d ='abcefg'
>>> it = iter(d)
>>> d = [x + next(it) for x in it] #creates a list
>>> d
['ab', 'ce', 'fg']
>>> d[0]
'ab'
>>> d[1]
'ce'
>>> d[2]
'fg'
Another way using zip:
>>> d ='abcefg'
>>> it = iter(d)
>>> [x+y for x,y in zip(it,it)]
['ab', 'ce', 'fg']
print_board? This has nothing to do with your original question.