String Methods
String methods let you search, split, transform, and test text without writing every character loop yourself. Learn the return value and missing-match behaviour of the method you choose.
Understand the idea
split creates pieces, partition returns a three-part result around the first separator, and find returns -1 when text is absent. startswith and endswith make intent clearer than slicing for a prefix test. Methods have different rules, so use one that describes the actual input format rather than chaining guesses until a sample happens to pass.
Where to try it
Open this example with Try in playground. The code loads as editable text and does not run until you select Run. The first run downloads Python. Each run starts fresh; temporary files created by a script are not files on your PC.
A worked example
line = "city=Nadiad"
key, separator, value = line.partition("=")
print(key, value)
print(line.startswith("city="))
Read the result
The first line displays city Nadiad and the second is True. separator holds the equals sign even though it is not printed.
Try one change
Try partition on a line without an equals sign and decide how your parser should reject or handle it.