livepython.net

72. Python Program to Print the First and Last Item of a List

EasyIndexing

Overview

Get items from a list by their index, from the front and from the back.

Problem Statement

Read three words, one per line, and store them in a list. Print the first item and the last item, using an index for each. For example, for red, green and blue:

First: red
Last: blue

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:

red
green
blue

Output

The output for that example:

First: red
Last: blue

The tests try 3 different inputs.

Learn this firstChapter 9 · Python List Index: Get and Change Items
solution.py
# write your code here

EXPECTED OUTPUT

1First: red
2Last: blue

YOUR OUTPUT

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