Pick from the List
Python
15 pts
Pick from the List
Use the list students to create four variables:
first— the first student.last— the last student (use a negative index).middle— a slice with the 2nd, 3rd and 4th students.count— the number of students, usinglen().
Print them in that order. Expected output:
Selam Yonas ['Merhawi', 'Abel', 'Hana'] 5
Checklist
- Keep the list
studentsunchanged. - Create
first(the first student) andlast(the last student, with a negative index). - Create
middle, a slice with the 2nd, 3rd and 4th students. - Create
count, the number of students, withlen(). - Print
first,last,middleandcount, in that order.
🔑 Solution
If you view the solution before passing, you earn half points for this exercise. You still need to type it and press Check to finish.
How it works, step by step
Point at a step to highlight its lines. Type the solution yourself and press Check answer to finish.
