Skip to content
Advertisement

Python between syntax (IF statement)

I am currently working on creating python automation tool based on excel file and basic idea of this project is allocation data into specific people automatically. However, I faced a small problem which is to make a condition for right allocation.

Data for conditions in Excel:

 column name -   email    |   longitude_min     |     longitude_max
              abc@gmail.com          92                        178
              def@gmail.com          92                        178
              ghi@gmail.com         -168                      -106
              jkl@gmail.com         -106                       69

Description : I’d like to allocate data based on above of the longitude min & max data and those data is stored in Excel file and I called those data as two lists.

 For abc@gmail.com, the longitude range would be 92 ~ 178
 For def@gmail.com, the longitude range would be 92 ~ 178
 For ghi@gmail.com, the longitude range would be -168 ~ -106
 For jkl@gmail.com, the longitude range would be -106 ~ 69

My Code :

    if now_lang_cnt>1:
    longitude = sheet_input.cell(i,longitude_index).value
    for j in range(0, emps_num):
        if lang2[j]==lang_name and : # Here is where I want to add a condition    
    print(country_name, lang_name, now_lang_cnt, longitude)

Expecting Conditions:

In sort, I would like to allocate data based on between ‘longitude_min’ and ‘longitude_max’ into specific email people’s email address.

Do you guys have any ideas how I should write the code for this condition ?

Advertisement

Answer

I think you mean longitude_min < longitude < longitude_max.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement