In a make task you use the skills you have learned to create a program from scratch. There is no starter code: you begin with an empty editor.
This one is all about getting data out of a list: one item at a time, two items joined together, the whole list at once, and finally an item the user picks.
So that the output can be checked automatically, the list is fixed. Start your program with exactly this line:
fruit = ["Apple", "Banana", "Grape", "Strawberry", "Melon", "Orange"]
It holds six items, so its indices run from 0 to 5.
Print seven lines, in this order.
+ to join them, and do not type either
fruit out in full.Banana. Work out its index and print it the same way as the first two.print.print, exactly as written:
Enter a number between 0 and 5:
Read the answer with a bare input() and cast it with int().
The first five lines are the same every time the program runs:
Strawberry
Orange
Apple Grape
Banana
['Apple', 'Banana', 'Grape', 'Strawberry', 'Melon', 'Orange']
Line five is what a whole list looks like when Python prints it: the square brackets, the quotes and the comma and space between each pair of items are all part of the output.
The sixth line is the question, printed exactly as written above, and the seventh is whichever item the user asked for, printed on its own.
Input:
0
Output:
Strawberry
Orange
Apple Grape
Banana
['Apple', 'Banana', 'Grape', 'Strawberry', 'Melon', 'Orange']
Enter a number between 0 and 5:
Apple
(index 0 is the first item in the list)
Input:
4
Output:
Strawberry
Orange
Apple Grape
Banana
['Apple', 'Banana', 'Grape', 'Strawberry', 'Melon', 'Orange']
Enter a number between 0 and 5:
Melon
Input:
5
Output:
Strawberry
Orange
Apple Grape
Banana
['Apple', 'Banana', 'Grape', 'Strawberry', 'Melon', 'Orange']
Enter a number between 0 and 5:
Orange
(index 5 is the last item, because a six-item list has no index 6)
The question is part of the output that is checked here, so its spelling,
capital letters and punctuation count. Ask it with its own print, exactly
Enter a number between 0 and 5:, and read the answer with a bare input()
on the next line, rather than passing the question to input(...).
Make sure that you check for the following things:
" ", between
the two items.int() before it is used as an
index.