How can I get the first child?
London
York
The current accepted answer gets all cities, when the question only wanted the first.
If you only need the first child, you can take advantage of .children
returning an iterator and not a list. Remember that an iterator generates list items on the fly, and because we only need the first element of the iterator, we don't ever need to generate all other city elements (thus saving time).
for div in nsoup.find_all(class_='cities'):
first_child = next(div.children, None)
if first_child is not None:
print(first_child.string.strip())