mardi 7 juin 2022

How do I categorize items in a list?

dataset = ['Apple', 'Banana', 'Mango', 'Grape', 'Pineapple',
           'Lettuce', 'Cabbage', 'Spinach', 'Carrot', 'Cauliflower']
ran = random.choice(dataset)
fruit = ['Apple', 'Banana', 'Mango', 'Grape', 'Pineapple']
vegetable = ['Lettuce', 'Cabbage', 'Spinach', 'Carrot', 'Cauliflower']

if ran == vegetable:
    print('HINT: It is a vegetable!')

 else:
    print('HINT: It is a fruit!')

First I categorized items in a list but when I run my code it would only say the else statement.




Aucun commentaire:

Enregistrer un commentaire