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
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"
577 PHP ssh2_scp_send fails to send files as intended
887 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
610 Uncaught (inpromise) Error on Electron: An object could not be cloned
568 Who developed the "avformat-59.dll" that comes with FFmpeg?
567 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
© 2024 OneMinuteCode. All rights reserved.