'F' → Fullscreen
Create a new Python program named 1-20-list-traversal-and-append.
for city in cities: to print every city, one per line.cities = ["Cleveland", "Chicago", "New York", "Dallas", "Seattle"]
for city in cities: print(city)for i in range(len(cities)): to print each city with its index.cities = ["Cleveland", "Chicago", "New York", "Dallas", "Seattle"]
for i in range(len(cities)): print(f"{i}: {cities[i]}")append(), list all tasks by traversal, or exit.tasks = []choice = ""
while choice != "3": print("1) Add task") print("2) List tasks") print("3) Exit") choice = input("Choose an option: ")
if choice == "1": new_task = input("Enter a task: ") tasks.append(new_task) print(f"{new_task} added.") elif choice == "2": for task in tasks: print(f"- {task}") elif choice == "3": print("Exiting.") else: print("Invalid option.")Verify your program works correctly.
1) Add task2) List tasks3) ExitChoose an option: 1 [Enter]Enter a task: Practice lists [Enter]Practice lists added.1) Add task2) List tasks3) ExitChoose an option: 1 [Enter]Enter a task: Finish homework [Enter]Finish homework added.1) Add task2) List tasks3) ExitChoose an option: 2 [Enter]- Practice lists- Finish homework1) Add task2) List tasks3) ExitChoose an option: 3 [Enter]Exiting.Answer the following questions before submitting your work.
for city in cities: and for i in range(len(cities)):? When would you need the second one?append() do to a list, and where does the new item get added?for loop instead of a while loop?Submit the required files to the appropriate dropbox.