Search the courses, subjects, tracks, games and features, or jump straight to a page.
2 cards from this section. Quick, good the night before a test.
What does fruits.append('orange') do?
Think about where the item is being added.
Use insert() to add 'mango' to index 2 in a list. What would it look like?
Remember the syntax for insert.
What does the append() method do?
Remember it's about the position of the addition.
Using insert(), what happens if you specify index 0?
Think about how lists are indexed.
Create a list of your favorite animals, and write a function that takes an animal name as an argument. If that animal is not in the list, append it; if it is, insert a new type of the same animal at the same position.
You'll want to check for membership before you decide what to do.
Imagine you manage a food list. Write a short script to ask users to input food items, appending them until they type 'quit'. After that, allow the user to input one more item that should be inserted at the first position.
Utilize loops to keep taking inputs!
4 more questions in this section. Enroll free to practise them all.
Enroll free