How to split a string into a list using Python

Configurare noua (How To)

Situatie

Split a string into a list where each word is a list item

Solutie

Pasi de urmat

txt = “This is a test”
x = txt.split()
print(x)

Output:

[‘welcome’, ‘to’, ‘the’, ‘jungle’]

Tip solutie

Permanent

Voteaza

(9 din 25 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?