# Finding the ending letter in a string

**URL:** <https://forum.inductiveautomation.com/t/finding-the-ending-letter-in-a-string/626>\
**Category:** Archived Topics\
**Created:** [April 3, 2008, 5:17pm UTC](https://forum.inductiveautomation.com/t/finding-the-ending-letter-in-a-string/626 "2008-04-03T17:17:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ron](https://avatars.discourse-cdn.com/v4/letter/r/ecae2f/32.png) [@Ron](https://forum.inductiveautomation.com/u/Ron)\
**Post date:** [April 3, 2008, 5:17pm UTC](https://forum.inductiveautomation.com/t/finding-the-ending-letter-in-a-string/626/1 "2008-04-03T17:17:17Z")

</div>

I have the following code snipit that I am trying to determine which tanks end with the letter ‘T’ and put them into the list transferList. I get an error on the line “if tank.endswith(‘T’)”. I give up. What am I doing wrong this time?

```auto
dsList = fpmi.db.toPyDataSet(event.source.parent.getComponent('MyCalendar').dsNextWeek)

tankList = dsList[0][myDay]
tankList = string.split(tankList,",")

for tank in tankList:
   if tank.endswith('T')
      transferList = transferList + tank
```

---

<div class="post-metadata">

**Author:** ![Ron](https://avatars.discourse-cdn.com/v4/letter/r/ecae2f/32.png) [@Ron](https://forum.inductiveautomation.com/u/Ron)\
**Post date:** [April 3, 2008, 5:47pm UTC](https://forum.inductiveautomation.com/t/finding-the-ending-letter-in-a-string/626/2 "2008-04-03T17:47:15Z")

</div>

Sorry for my blunder. I just noticed that I left off the : after the “if” statement. 😊

---

<div class="post-metadata">

**Author:** ![MickeyBob](https://avatars.discourse-cdn.com/v4/letter/m/e19adc/32.png) [@MickeyBob](https://forum.inductiveautomation.com/u/MickeyBob)\
**Post date:** [April 12, 2008, 10:30pm UTC](https://forum.inductiveautomation.com/t/finding-the-ending-letter-in-a-string/626/3 "2008-04-12T22:30:09Z")

</div>

FYI, there is an alternative to the string.endswith() method. You could use Jython/Python string slicing as in the following:

```auto
if tank[-1] == 'T':
```
