3

Let's say I have the following ascii hex string "4a65737573". How do I now iterate over it, wrapping a fixed amount of characters, but always incrementing by 2. i.e. 4a65, 6573, 7375...

Dark
  • 803
  • 2
  • 8
  • 23

1 Answers1

16

This should do it:

In [218]: mystr =  "4a65737573"

In [219]: for i in range(0, len(mystr), 2):
   .....:     print mystr[i:i+4]
   .....:     
4a65
6573
7375
7573
73
inspectorG4dget
  • 110,290
  • 27
  • 149
  • 241