Netbyzz

#B031

Python :

#CODE = #B031
# Initialize the list with burgers and fries
fast_food = ["Burger", "Burger", "Fries"]

# Append a burger to the list
fast_food.append("Burger")
print(f"After append: {fast_food}")

# Clear the list
fast_food.clear()
print(f"After clear: {fast_food}")

# Reinitialize the list for further operations
fast_food = ["Burger", "Burger", "Fries"]

# Count the number of burgers in the list
burger_count = fast_food.count("Burger")
print(f"Burger count: {burger_count}")

# Copy the list
fast_food_copy = fast_food.copy()
print(f"Copy of the list: {fast_food_copy}")

# Find the index of fries in the list
fries_index = fast_food.index("Fries")
print(f"Index of fries: {fries_index}")

# Insert a drink at position 1
fast_food.insert(1, "Drink")
print(f"After insert: {fast_food}")

# Pop the item at index 3
popped_item = fast_food.pop(3)
print(f"Popped item: {popped_item}")
print(f"After pop: {fast_food}")

# Remove fries from the list
fast_food.remove("Drink")
print(f"After remove: {fast_food}")

# Insert a drink at position 2
fast_food.insert(2, "Drink")
print(f"After insert: {fast_food}")

# Reverse the list
fast_food.reverse()
print(f"After reverse: {fast_food}")

Source Code