Traversing a list
Q1. Get the following working in Python:
monsters=['goblin', 'orc', 'evil pixie', 'ogre', 'firedog']
extra_evil=['mummy','witch','wizard']
print('There are',len(monsters),"monsters in the monster's list.")
print(monsters)
i=0
while i<len(monsters):
print(monsters[i])
i += 1
Q2. Describe what the program above does.
Q3. In this line:
print('There are',len(monsters),"monsters in the monster's list.")
why were double quotes used around "monsters in the monster's list" and not single quotes as used before?
Q4. Modify the program so that the monsters list is extended using the extend method and the extra_evil list. Print out the monsters list and all the items in it and check it is correct.
Q5. In addition to printing out each monster, print out the total number of characters (including spaces) in each monster's name.
Q6. Using the pop method, remove the third item in the list. Then display the monsters list again, along with the length of characters in each name and the monster that was removed from the list.
Q7. Add code to the end of your program to print out the list in reverse order. HINT: Start by creating a variable to hold the length of the list.
Q8. Create a new list of evil monsters.
Q9. Extend your monsters list using this list.
Q10. Print out the final list of monsters.