String Partition in Python
Level 3114 keystrokes
This splits a string into three parts using partition(). It returns the part before, the separator, and the part after.
Python code
# An email address to split at @1text = "hello@world.com"# partition("@") splits at the first @ and returns (before, separator, after)# Unpacking gives local="hello", separator="@", domain="world.com"2local, separator, domain = text.partition("@")# Only local and domain are used: prints "Local: hello, Domain: world.com"3print(f"Local: {local}, Domain: {domain}")Output
Local: hello, Domain: world.com
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.
"× 6,× 3:× 2.× 2(× 2)× 2{× 2}× 2@× 2=× 2