Tuple inside list Python code example
Example 1: python list of tuples
list_tuples = [('Nagendra',18),('Nitesh',28),('Sathya',29)]
for name,age in list_tuples:
print(name,age)
for index,(name,age) in list_tuples:
print(f'My name is {name} and age is {age} and index is {index}')
print('My name is {n} and age is {a} and index is {i}'.format(n=name,a=age,i=index))
Example 2: tuple in python
tup = ('a','b','c')
Example 3: searching in a tuple python
vowels = ('a', 'e', 'i', 'o', 'i', 'u')
index = vowels.index('e')
print('The index of e:', index)
index = vowels.index('i')
print('The index of i:', index)