0

So I have string like this:

"UFFKTEWKW"

And I need to convert it to a list or tuple like this:

("UFF", "KTE", "WKW")

So every 3 letters from the string goes to separate element of list or tuple.

I can't use split() here because string doesn't have any delimiters. I don't wanna make some dummy for cycle for it. And I think there should be simple solution for it.

1 Answers1

0

You can use this.

a="UFFKTEWKW"
out=tuple(a[i:i+3] for i in range(0,len(a),3))
# ('UFF', 'KTE', 'WKW')
Ch3steR
  • 20,090
  • 4
  • 28
  • 58