String Split in Python
Level 239 keystrokes
This splits the string 'a,b,c,d' by commas and prints ['a', 'b', 'c', 'd']. split() divides a string into a list.
Python code
# Assign a comma-separated string to the variable text1text = "a,b,c,d"# split() is a string method that divides a string into parts# The argument "," tells it where to split (at each comma)# Returns a list: ['a', 'b', 'c', 'd']2print(text.split(","))Output
['a', 'b', 'c', 'd']
Practice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this Python code and how often they appear.
,× 4"× 4(× 2)× 2.× 1=× 1