Adding elements to a tuple when I know I shouldn't be able to
[Dive Into Python][1] is one of many sources that says:

> You can't add elements to a tuple.

But it looks as if I was allowed to do just that. My code:

    from string import find

    def subStringMatchExact(target, key):
        t = (99,)
        location = find(target, key)
        while location != -1
            t += (location,)    # Why is this allowed?
            location = find(target, key, location + 1)
        return t

    print subStringMatchExact("atgacatgcacaagtatgcat", "tg")

Output:

    (99, 1, 6, 16)

This leads me to believe that I am not actually creating a tuple when I initialize `t`. Can someone help me understand?


  [1]: http://diveintopython.org/getting_to_know_python/tuples.html "Dive Into Python"
Adding elements to a tuple when I know I shouldn't be able to
===

[Dive Into Python][1] is one of many sources that says:

> You can't add elements to a tuple.

But it looks as if I was allowed to do just that. My code:

    from string import find

    def subStringMatchExact(target, key):
        t = (99,)
        location = find(target, key)
        while location != -1
            t += (location,)    # Why is this allowed?
            location = find(target, key, location + 1)
        return t

    print subStringMatchExact("atgacatgcacaagtatgcat", "tg")

Output:

    (99, 1, 6, 16)

This leads me to believe that I am not actually creating a tuple when I initialize `t`. Can someone help me understand?


  [1]: http://diveintopython.org/getting_to_know_python/tuples.html "Dive Into Python"