String Partition in Python
Level 261 keystrokes
This splits a string into three parts using partition().
Python code
# Create a string that contains one "-" separator1text = "hello-world"# partition("-") splits at the first "-" and always returns a 3-tuple# The tuple is (before, separator, after); if "-" is missing it is (text, "", "")2parts = text.partition("-")# Prints ('hello', '-', 'world')3print(parts)Output
('hello', '-', 'world')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-× 2(× 2)× 2=× 2.× 1