How would i use and if and else statement in a list? Like if i have a premade list then a user inputs their list how would I make it to where it displays we entered the same answer. this is the assignment:
Pick a category and make a list of your five favorite things. Suggested categories include your favorite: actors, books, cars, or something else of your choosing.
Ask the user what their favorites are in your selected category.
By creating a list, a loop, and if statements, print a message that lets the user know if their favorites matches the ones on your list.
Neatly print your entire list to the screen. Be sure to number each item.
Write the pseudocode for this program. Be sure to include any needed input, calculations, and output.
Here is my current code:
def main():
print("What are your five favorite cars?")
favoriteCarOne = input("What is your first favorite car?")
favoriteCarTwo = input("What is your second favorite car?")
favoriteCarThree = input("What is your third favorite car?")
favoriteCarFour = input("What is your fourth favorite car?")
favoriteCarFive = input("What is your fifth favorite car?")
userCarList = [favoriteCarOne, favoriteCarTwo, favoriteCarThree, favoriteCarFour, favoriteCarFive]
daltonCarList = ["Shelby", "Dodge HellCat", "Nissian GT-R R34", "Ford Focus RS", "Corvette ZR1"]
for n in range(0, len(userCarList)):
print(str(n) + " " + userCarList[n])
daltonLength = len(daltonCarList)
userLength = len(userCarList)
if (userCarList == daltonCarList):
print("Cool! We like the same cars!")
print
else:
print("Those are cool cars!")
print
print("These are my favorite cars!")
print(daltonCarList)
print
main()