O'Reilly logo
  • Longxiang Lyu thinks this is interesting:

4-13. Buffet:


Cover of Python Crash Course


if need to update tuple, get it as list.

foods = ('pizza', 'burger', 'taco', 'meat ball', 'burrito') print("foods to offer:") for food in foods: print(food) print("\nbuffet decide to offer steak instead of meat ball!") tmp = list(foods) tmp[tmp.index("meat ball")] = "steak" foods = tuple(tmp) print("new list:") print(foods)