Take 2 letters in python | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 1

Take 2 letters in python

I was making a project, and I came across an unsolved problem. So for example I have a string: this is book. Then how to make the string into a list like this: ["th", "is", "is", "bo", "ok"] Also see that spaces are removed

9th Oct 2020, 12:31 AM
Muhammad Malik Ali
Muhammad Malik Ali - avatar
1 Antwort
+ 2
string ="".join(input().split(' ')) string = [string[i:i+2] for i in range(0,len(string),2)] print(string)
9th Oct 2020, 1:08 AM
Ruba Kh
Ruba Kh - avatar