I want to create a program, where you have join words. Example:
Computer asks: Write this word in French: (english word, generated randomly)
You answer: (the word in French)
IF IT IS CORRECT:
- Computer: correct
IF IT IS INCORRECT:
- Computer: incorrect
I want to have setted multiple words (like 50 words) and I want computer to pick randomly and i wanna have for every world to have this word in French. (I wanna set the words manually)
I hope that this question is not that messy as I thing. I didnt knowed how to ask it, so hope thats good.
Thanks for all the answers.
CodePudding user response:
this should do the trick:
import random
words = {"yes": "wi","no": "no"} #you need to manually enter 50 words hre
shuffeled_keys = list(words.keys())
random.shuffle(shuffeled_keys)
for eng_word in shuffeled_keys:
fr = input("how do you say %s in France"%eng_word)
if fr == words[eng_word]:
print("correct")
else:
print("incorrect")
if you have any questions feel free to ask me in the comments, and if my code helped you, please consider marking it as the answer :)
CodePudding user response:
you should write dictionary of words, i will write a script for you to get the idea clear:
import random
dict = {'apple' : 'pomme', 'banana':'banane','car':'auto'}
english_words = list(dict)
print(english_words)
max = len(dict) - 1
while(1):
en = english_words[random.randint(0,max)]
fr = input('Write ' en ' in French: ')
if(dict[en] == fr):
print('correct')
else:
print('incorrect')