Santa has created a Naughty and Nice list. He wants a program which will do the following: -
*Ask someone their name
*Ask them if they're naughty or nice
*If they're naughty, then they should go onto the naughty list
*If they're nice, then they should go onto the nice list
*You may need two lists
Use the programming code examples to help you. I've included some print screens.
Your job is to combine these skills to create the program for Santa.
Don't forget the name of your variables while you're doing this. You can use the picture to help you.
Creating a list
names = ["Mr Chambers", "Mr Smith", "Mrs Khan", "Mr Kumar"]
In the example above, you have a list of 4 names. If I want to see who is the first name in the list, I can simply write out.
print(names[0])
This would output Mr Chambers.
You can print out the whole list by typing print(names)
Adding to the end of the list
If I want to add someone to the end of the list, I can do this:
newname = input("What is the name of the person you want to add?")
names.append(newname)
Selection
Here is some helpful code. Santa wants to add people to the naught or nice list. If they're naughty then they should go on the naughty list. If they're nice then they need to go on the nice list. The structure of the code below shows you how to do part of this problem. This programming technique is called 'selection' it means you can change the outcome of your program.
naughtyornice = input("Are you naughty or nice?")
if naughtyornice == "naughty":
print("You're naughty") # What could you change this to?
else:
print("You're nice") # What could you change this to?