# String Format byte order

**URL:** <https://forum.inductiveautomation.com/t/string-format-byte-order/55276>\
**Category:** Ignition\
**Created:** [January 21, 2022, 10:14pm UTC](https://forum.inductiveautomation.com/t/string-format-byte-order/55276 "2022-01-21T22:14:03Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [January 24, 2022, 3:44pm UTC](https://forum.inductiveautomation.com/t/string-format-byte-order/55276/4 "2022-01-24T15:44:12Z")

</div>

Just so you don’t scratch your head for too long on this:

```python
s = "eRicep1 32"
s = ''.join(c for pair in zip(s[1::2], s[::2]) for c in pair)

```

`s[1::2]` and `s[::2]` will produce strings with even or odd characters ([1::2] = start from 1, stop at the end, step 2),  
`zip` will take one character from each,  
then it’s simply a matter of putting things in the right order.  
So, with `"eRicep1 32"`, `s[1::2]` will be `"Rcp 2"` and `s[::2]` `"eie13"`  
`zip("Rcp 2", "eie13")` produces the pairs `[('R', 'e'), ('c', 'i'), ('p', 'e'), (' ', '1'), ('2', '3')]`  
and iterating through those pairs and picking single extracts them from the tuples to produce the list `['R', 'e', 'c', 'i', 'p', 'e', ' ', '1', '2', '3']`  
All that’s left to do is join them on nothing with `''.join()`

There might be libraries with builtins for this, but, well…

---

_[View the full topic](https://forum.inductiveautomation.com/t/string-format-byte-order/55276)._
