xxxxxxxxxx
>>> a = [(1, u'abc'), (2, u'def')]
>>> [i[0] for i in a]
[1, 2]
xxxxxxxxxx
tuple_list = [("a", "b"),("c", "d")]
first_tuple_elements = []
for a_tuple in tuple_list:
first_tuple_elements.append(a_tuple[0])
print(first_tuple_elements)
#OUTPUT: ['a', 'c']
xxxxxxxxxx
tuple_name = (1, 2, 3) # Example tuple
first_element = tuple_name[0]
print(first_element)
xxxxxxxxxx
List<(string, int)> tupleList = new List<(string, int)>()
{
("Apple", 10),
("Banana", 20),
("Orange", 30)
};
string firstElement = tupleList[0].Item1;