Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
文字列を 2 で分割するにはどうすればよいですか。たとえば、「string」は「st」、「ri」、「ng」のグループに分割されます。ドキュメントを確認すると、 itertools の groupby が必要なようです。しかし、 itertools を使用しないで簡単にそれを行う方法はありますか? ありがとう
s='your input string' ans=[ ] i=0 while i < len(s): ans.append( s[ i:i+2 ] ) i+=2 print ans