Question about creating a word memorization program with Python list

Asked 2 years ago, Updated 2 years ago, 19 views

Hello, I'm a person who just started coding. I'm just learning on my own by looking at the Internet, but I was bored, so I was writing down about memorizing German words, and I had a question on Stackoverflow, so I left a question and got an answer, but I left it here because I didn't understand. Here's the code I received in response.

words_and_answers = [("abhängen ", "von"), ("abrechnen ", "mit")]

random.shuffle(words_and_answers)

for input_word, correct_answer in words_and_answers:
  while True:
    user_response = input(input_word)
    if user_response == correct_answer:
      print("You're right")
      break
    else:
      print(`Wrong")

You can see, if you see the word abhgngen, you can type the word von to tell if it's right or not, but I don't know how the word abhnngen comes out on the console no matter how much I wash my eyes. The print function was only used to print whether the correct answer was correct or not.

python

2022-09-20 08:40

1 Answers

https://docs.python.org/3/library/functions.html#input

If the prompt argument is present, it is written to standard output without a trailing newline. The function then reads a line from input, converts it to a string (stripping a trailing newline), and returns that. When EOF is read, EOFError is raised. Example:

>>>
>>> s = input('--> ')  
--> Monty Python's Flying Circus
>>> s  
"Monty Python's Flying Circus"


2022-09-20 08:40

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.