if ruswords: print('\n', r) ruswords = False myanswer = input('print translation') while…
- User
if rus_words: print('\n', r) rus_words = False my_answer = input('print translation') while my_answer != r: print('wrong, try again') continue if keyboard.on_press_key('space'): break
- Assistant
I see you are trying to create a simple translation program in Python. It seems like you want to prompt the user to input the translation of a Russian word and then compare it to the correct translation.
One thing to note is that the use of
keyboard.on_press_key('space')may not work as expected in this context. Instead, you can utilize a condition that checks if the user wants to exit the loop, or if you want to keep it running until the user inputs the correct translation.Here is a modified version of your code snippet:
rus_words = True if rus_words: r = 'Привет' # This is just an example Russian word print('\n', r) rus_words = False my_answer = input('print translation: ') while my_answer != r: print('Wrong, try again') my_answer = input('print translation: ') print('Correct!')This code will prompt the user to input the translation of the Russian word, and will keep asking until the correct translation is entered. Feel free to adjust it further based on your specific requirements.