Drop links or images here to add them to the editor.

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 an independent challenge. It is short, but it puts three things together at once: a list, input from the user, and replacing an item in a list by assigning to its index.

The program shows a list of five names, lets the user say who they are and which place in the list they want, and puts them there in place of whoever was standing in it.

The data

So that the output can be checked automatically, the five names are fixed. Start your program with exactly this line:

names = ["Alex", "Anita", "Patrick", "Atif", "Sue"]

Your task

  1. Print the whole list, in one go, so the user can see the five names and the positions they are in.
  2. Ask the user what their name is, and store the answer in a variable. Ask the question with its own print, exactly as written:
    What is your name?
    
  3. Ask the user for a number between 0 and 4, and store the answer in a variable. Ask this question the same way, exactly as written:
    Enter a number between 0 and 4:
    

    Cast it with int(), because it is going to be used as an index.

  4. Replace the item at that position in the list with the user’s name. Do not add the name to the list and do not remove anything: assigning to an index swaps one item for another and leaves the list five names long.
  5. Print the whole list again, so the change can be seen.

Read both answers with a bare input() on the line after its question.

The output

Your program prints exactly four lines: the list before the change, the two questions, and the list after the change.

The first line is the same every time the program runs:

['Alex', 'Anita', 'Patrick', 'Atif', 'Sue']

The next two lines are the two questions, printed exactly as written above.

The fourth line is the same list with one name swapped for the one the user typed. It still has five items, with the square brackets, quotes and commas that Python puts round a printed list:

['Alex', 'Anita', 'Tom', 'Atif', 'Sue']

Example

Input:

Tom
2

Output:

['Alex', 'Anita', 'Patrick', 'Atif', 'Sue']
What is your name?
Enter a number between 0 and 4:
['Alex', 'Anita', 'Tom', 'Atif', 'Sue']

(Tom takes the place of Patrick, the item at index 2)


Input:

Jo
0

Output:

['Alex', 'Anita', 'Patrick', 'Atif', 'Sue']
What is your name?
Enter a number between 0 and 4:
['Jo', 'Anita', 'Patrick', 'Atif', 'Sue']

(index 0 is the first name, so Alex is the one that goes)


Input:

Mary Jane
4

Output:

['Alex', 'Anita', 'Patrick', 'Atif', 'Sue']
What is your name?
Enter a number between 0 and 4:
['Alex', 'Anita', 'Patrick', 'Atif', 'Mary Jane']

(index 4 is the last name, because a five-item list has no index 5)

Both questions are part of the output that is checked here, so their spelling, capital letters and punctuation count. Ask each one with its own print, exactly What is your name? and Enter a number between 0 and 4:, and read the answer with a bare input() on the next line, rather than passing the question to input(...).

Help! My code doesn't work!

Make sure that you check for the following things:

  • The list name is spelled identically everywhere it is used, capital letters included.
  • The index is surrounded by square brackets.
  • List indexing starts at zero. Are you counting properly?
  • The largest index in this list is 4, not 5.
  • The number the user types is wrapped in int() before it is used as an index.
  • The list name on the left of the = has the index after it, as in names[position] = your_name. Without the index you would replace the whole list with one name.
  • Printing the whole list uses the list name without any square brackets after it.