Created
September 24, 2021 06:48
-
-
Save SaraM92/70447f9ea8c083a6e5b93430a8f3430f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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