If you want to avoid that lengthy if-elif-else block, you can try dictionary method as below- def coder(val): cod_val = {'Divisional Boundary':'DIV','District Boundary':'DIST','Thana Boundary':'THAN','Upazilla Boundary':'UPAZ','International Boundary':'INTL','Union Boundary':'UN','Ward Boundary':'WRD'} return cod_val.get(val,"Not Found") for tables like- [![table][1]][1] **Description of functions:** This function takes a text parameter and get the corresponding text value from the dictionary as defined inside the function. If the input parameter value is not found in that dictionary then **default value** **("Not Found")** is returned. [1]: https://i.sstatic.net/9BYRj.png