定义一个元组,内容是:(‘李四’, 11, [‘football’, ‘music’]),记录的是一个学生的信息(姓名、年龄、爱好)
请通过元组的功能(方法),对其进行
查询其年龄所在的下标位置
查询学生的姓名
删除学生爱好中的football
增加爱好:coding到爱好list内
tuple_1 = ('李四', 11, ['football', 'music'])
print(f'原元组为:{tuple_1}')
age = tuple_1.index(11)
print(age)
name = tuple_1[0]
print(name)
tuple_1[2].remove('football')
print(f'删除后的元组为:{tuple_1}')
tuple_1[2].append('coding')
print(f'增加后的元组为:{tuple_1}')
"""
list_tuple_1 = list(tuple_1)
print(list_tuple_1)
list_tuple_1[2].remove('football')
# del list_tuple_1[2][0]
# list_tuple_1.insert(2, 'coding')
tuple_1 = tuple(list_tuple_1)
print(f'删除后的元组为:{tuple_1}')
tuple_1 = ('李四', 11, ['football', 'music'])
list_tuple_1 = list(tuple_1)
list_tuple_1[2].append('coding')
tuple_1 = tuple(list_tuple_1)
print(f'增加后的元组为:{tuple_1}')
"""
"""
for element in tuple_1:
if element == 'football':
continue
"""
"""
del tuple_1[tuple_1.index('football')]
print(f'删除后元组为:{tuple_1}')
num = tuple_1.index(['football', 'music'])
print(num)
"""