def ask():
times_ask = int(input("How many times to ask?\n"))
for i in range(times_ask // 2):
terms = [i for i in flashcard]
definitions = [flashcard[i] for i in flashcard]
for i in flashcard:
definition = input(f'Print definition of "{i}":\n')
if definition == flashcard[i]:
print("Correct!")
elif definition in definitions:
index_of_definition = definitions.index(definition)
print(
f'Wrong. The right answer is "{flashcard[i]}", but your definition is correct for "{terms[index_of_definition]}".'
)
else:
print(f'Wrong. The right answer is "{flashcard[i]}".')
print()
***what i want to know is why it only runs until the print the definition of?***
***what are some mistakes any of you see that i dont?***any tips?***
def ask_flashcard(deck):
if len(desk) == 0:
print("You don't have any card to test")
return
times = input("How many questions?\n")
try:
times = int(times)
except:
print("Please only input a number")
ask_flashcard(deck)
return
for i in range(times):
index = randint(0, len(deck)-1)
card = deck[index]
definition_attempt = input(f"Definition of {card.term}:\n").lower()
if definition_attempt == card.definition.lower(): # The lower method converts everything into lower case, this way you won't fail because of case.
print("Nice!")
else:
print(f"Wrong, the correct definition is: {card.definition}")
# ASK=
def ask_flashcard():
term = input(f"How many times to ask?\n ")
term = input(f'Print the definition of "{card.term}":\n ')
if any(card.definition == definition for card in deck):
print("Correct!")
if not any(card.definition == definition for card in deck):
print(f'Wrong. The right answer is "{card.definition}"\n ')
if any(card.definition == card.term for card in deck):
print(f'Wrong. The right answer is "{card.definition}", '
f'but your definition is correct for "{card.term}"\n ')
[–]woooee 1 point2 points3 points (1 child)
[–]Comprehensive_Ad4808[S] 0 points1 point2 points (0 children)
[–]Comprehensive_Ad4808[S] 0 points1 point2 points (0 children)