Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python - matching people based on city

students = [
    {
     'name': 'Sarah',
     'city': 'Manchester'
    },
    {
     'name': 'Mary',
     'city': 'London'
     }
    ,
    {
     'name': 'Charlotte',
     'city': 'Paris'
     },
    {
     'name': 'Carl',
     'city': 'Paris'
     }  
]

 

my_location = input('Which is your location?  ')
match_location = [student for student in students if student['city'] == my_location]
 
  
# Option 1     
if len(match_location) > 0:
    print('The location is:')    
    
    
# Option 2
if any(match_location):
    print('The location is:') 
Comment

PREVIOUS NEXT
Code Example
Python :: How to put a header title per dataframe after concatenate using pandas in python 
Python :: how to predict the output for new data with the model tested already 
Python :: remove repetitive characters from the specified column of a given DataFrame 
Python :: paschat opposite sanskrit 
Python :: the process of delivery of any desisered data 
Python :: python selenium not returning correct source 
Python :: remove words from set if in list python site:stackoverflow.com 
Python :: python round and map function 
Python :: pandas resample fill missing values 
Python :: Separating a relational plot based on a sixth variable | seaborn relational plot 
Python :: iterating over the two ranges simultaneously and saving it in database 
Python :: fibonacci series recursive python 
Python :: removing stop words in python 
Python :: how to store svgs in django image field with SVGAndImageFormField 
Python :: using default as none in django mdoels 
Python :: python tokenize sentence italian spacy 
Python :: json timestamp to date python 
Python :: string float to round to 2dp python 
Python :: mechanize python #9 
Python :: sort dictionary by values 
Python :: how to get the original start_url in scrapy 
Python :: how to convert nonetype to list in python 
Python :: space separated dictionary input in python 
Python :: KeyError: 0 
Python :: Data Analytics with Pandas – How to Drop a List of Rows from a Pandas Dataframe 
Python :: python list find 
Python :: Code Example of Comparing None with False type 
Python :: extract tables from image python 
Python :: pthalic acid 
Python :: python adding an item 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =