replit

Before you start this course, you must login to Replit

If you have forgotten your Replit account user name or password, ask your Coder Coach.

Output A Range Of Items From A List

Need more help with lists? Click here

Modify

What’s a Modify task?

In the modify tasks, you are given some starter code. Use the instructions below to make changes to the code. Comment your changes to explain what you have done.

Adapt the code so that:

  • It asks the user to enter a number between 0 and the last index of the list (hint – you’ll need to subtract 1 from the length of the list).
  • It validates the input so that users can’t enter a number smaller than 0 or bigger than index of the last item in the list.
  • It asks the user to input a second number between the first number input + 1 and the last index of the list.
  • It validates the input so that users have to input a number bigger than the first input and less than or equal to than index of the last item in the list.
  • It prints the items in the list between the two numbers input.

Help! My code doesn’t work

Make sure that you check for the following things:

  • Square brackets for items in the list
  • Commas between each item in the list.
  • String items are in quotation marks
  • Range – the end value is NOT included in the output.
  • Search – not initialising counter OUTSIDE the loop.
  • Search – not incrementing counter INSIDE the loop.

Hints