I have postcodes which I need to cut down from say BN14 5RY to only BN14. I cannot simply use the 'left(input, n)' equation as some postcodes are only 6 figures long such as BN1 5RY and I always need the first 3/4 characters.
Does anyone know a way to delete the last 3 characters?
Thanks in advance.
>>> a = "abcdefghijklmnop" >>> b = a[:-4] >>> b 'abcdefghijkl' >>>
If your field contains string/text data, there is no need for the len method in Python since string data is an "iterable". For example>>> a = "abcdefghijklmnop" >>> b = a[:-4] >>> b 'abcdefghijkl' >>>
"BN14 5RY".split() # or "BN1 5RY".split()