Python newbie clarification about tuples and strings
<p>I just learned that I can check if a substring is inside a string using:</p>

<blockquote>
  <p>substring in string</p>
</blockquote>

<p>It looks to me that a string is just a special kind of tuple where its elements are chars. So I wonder if there's a straightforward way to search a slice of a tuple inside a tuple. The elements in the tuple can be of any type.</p>

<blockquote>
  <p>tupleslice in tuple</p>
</blockquote>

<p>Now my related second question:</p>

<pre><code>&gt;&gt;&gt; tu = 12 ,23, 34,56
&gt;&gt;&gt; tu[:2] in tu
False
</code></pre>

<p>I gather that I get False because (12, 23) is not an element of tu. But then, why substring in string works?. Is there syntactic sugar hidden behind scenes?.</p>

<p>This is how I accomplished to do my first request, however, it's not straightforward nor pythonic. I had to iterate the Java way. I wasn't able to make it using "for" loops.</p>

<pre><code>def tupleInside(tupleSlice):
    i, j = 0, 0
    while j &lt; len(tu):
        t = tu[j]
        ts = tupleSlice[i]
        print(t, ts, i, j)
        if ts == t:
            i += 1
            if i == len(tupleSlice):
                return True
        else:
            j -= i
            i = 0
        j += 1
    return False

tu = tuple('abcdefghaabedc')
print(tupleInside(tuple(input('Tuple slice: '))))
</code></pre>

python string tuples