Skip to content

Instantly share code, notes, and snippets.

@SaraM92
Created September 24, 2021 06:48
Show Gist options
  • Save SaraM92/70447f9ea8c083a6e5b93430a8f3430f to your computer and use it in GitHub Desktop.
Save SaraM92/70447f9ea8c083a6e5b93430a8f3430f to your computer and use it in GitHub Desktop.
addresses = ["123 Elm Street", "531 Oak Street", "678 Maple Street"]
street = "Elm Street"
#The top 2 methods to check if street in any of the items in the addresses list
#1- Using the find method
for address in addresses:
if address.find(street) >= 0:
print(address)
#2- Using the "in" keyword
for address in addresses:
if street in address:
print(address)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment