I created a list in python so it is easier to recall my if/else statements. However I keep getting a NameError when answering the question prompted by my code. Any ideas in how I should proceed to fix this?
My code:
random_number = random.randint(1, 51)
question = str(input(f'Does {random_number} represent a cat or dog? '))
dog_list = [pug, retriever, poodle]
cat_list = [siamese, tabby, persian]
if (random_number%2 == 0) and (question == dog_list):
print("Correct")
elif not(random_number%2 == 0) and (question == cat_list):
print("Correct")
else:
print("Incorrect")
def EvenOdd(random_number):
if random_number%2 == 0:
return"Even"
else:
return "Odd"
Aucun commentaire:
Enregistrer un commentaire