📜  将项目附加到元组 python 代码示例

📅  最后修改于: 2022-03-11 14:46:43.081000             🧑  作者: Mango

代码示例3
apple = ('fruit', 'apple')
banana = ('fruit', 'banana')
dog = ('animal', 'dog')
# Make a list with these tuples
some_list = [apple, banana, dog]
# Check if it's actually a tuple list
print(some_list)
# Make a tuple to add to list
new_thing = ('animal', 'cat')
# Append it to the list
some_list.append(new_thing)
# Print it out to see if it worked
print(some_list)