livepython.net

76. Python Program to Add Items to a Shopping List

EasyAdd, remove

Overview

Grow a list with append() and insert().

Problem Statement

Start with the list ["milk", "bread"]. Read two items, one per line. Add the first item to the end of the list and the second item to the front. Then print the list and the number of items. For example, for eggs and rice:

['rice', 'milk', 'bread', 'eggs']
Items: 4

Use input() with no prompt text: the tests type the input for you, and a prompt would end up in your output.

Input

One value per line, in this order. Example:

eggs
rice

Output

The output for that example:

['rice', 'milk', 'bread', 'eggs']
Items: 4

The tests try 3 different inputs.

Learn this firstChapter 9 · Add and Remove Items in a Python List
solution.py
# write your code here

EXPECTED OUTPUT

1['rice', 'milk', 'bread', 'eggs']
2Items: 4

YOUR OUTPUT

Press Run to see your output here. Lines are compared with the expected output.