# 1、 Definition of tuple
t = tuple('python')
t1 = ('p', 'y', 't', 'h', 'o', 'n')
t2 = ('my', 'name', 'is', 'datian')
t3 = 'my', 'age', 'is', 20
t4 = ('solo' ,)
print(t)
print(t4)
print(t1)
print(t1[2])
print(t1[:2]) # Take two small tuples from the large tuple , amount to java In the array ,python Tuples in are immutable sequences
# 2、 Tuple operation
# 1)join meaning : Take the following as an example , Will be Space perhaps + Add to the middle of every string , Finally, put them together into a large string
# remarks :t1 All elements in the must be of string type
print(" ".join(t1))
print("+".join(t1))
t5 = 'd', 'a', 't', 'i', 'a', 'n'
# 2)count function : Count how many a
print(t5.count('a'))
# 3)index function : see a In which position , If there is no error report
print(t5.index('a'))
# 4) Tuple length
print(len(t5))
t6 = tuple(range(100))
print(len(t6))
print(t6[-1])
# Determine whether a tuple contains an element
# Example :999 Is here or not t6 in
print(999 in t6)
# Cycle through each data in the tuple
t7 = ('d', 'a', 't', 'i', 'a', 'n')
# Method 1
for i in t7:
print(i)
# Method 2
i = 0
while i < len(t7):
print(t7[i])
i += 1