How to compare the value in a string list with another value in a string list and if I do succeed in comparing with 2 of the lists, how can I store a new value in a new list if the value in the string lists is matches?
def start_game():
food_list = ["salad", "steak", "fries", "rice", "noodles", "fruits"]
random_food_list = [random.choices (food_list, k = 4)]
player_guess_list = []
correct_guess_list = []
for i in range(1,5):
player_guess = input("food" + str(i) + ":").lower()
if player_guess not in food_list:
print("Invalid foods, Restart Again")
start_game()
else:
player_guess_list.append(player_guess)
print(player_guess_list) # For review
print(random_food_list) # For review
For example:
User input list = [salad, steak, noodles, rice]
randomized list = [salad, rice, salad, rice]
correct_guess_list = [O,X,X,O]
Output
Correct food in correct place: 2
Correct food in wrong place: 2