-3

I'm attempting to make a Japanese study program in python. It will display a word randomly from a list, but only once, until all the words are used. After each word, is displayed the user will input the translation. If it's wrong, it will say so and add one to an accumulator that displays after all the words are used. Same goes if it's right.

I'd appreciate help concerning how to randomize the words and making sure that they are only displayed once.

Nikana Reklawyks
  • 3,233
  • 3
  • 33
  • 49
  • 3
    nice, so what do you have so far? – monkut Oct 05 '12 at 03:06
  • So far I have the start of the program which asks what chapter of vocab and asks if the user wants to study in the form of Japanese to English or English to Japanese. I'm working on the part that comes after that, which is a lot of functions that will basically have close to the same code. – Jordan Dent Oct 05 '12 at 03:19
  • you should post the code you're having trouble with. – monkut Oct 05 '12 at 03:31
  • I don't know how to post the code properly so that its nice and formatted and all of that. I'm basically a noob to this site. – Jordan Dent Oct 05 '12 at 04:16
  • no prob, the beginning is a good place to start! – monkut Oct 05 '12 at 04:52
  • copy, paste, highlight, click the "{}" button. – monkut Oct 05 '12 at 05:03

2 Answers2

3

The part that I need help with is the randomizing of the words and making sure that they are only displayed once.

Before starting, randomize the list of words, and then just iterate over it in-order.

import random

words = ['foo', 'bar', 'baz', 'quux']
random.shuffle(words)

for word in words:
    # TODO prompt for translation
    print word
Community
  • 1
  • 1
Matt Ball
  • 354,903
  • 100
  • 647
  • 710
0

I'm not all that familiar with python, so I don't know the exact syntax or data structures you have available. My basic idea is to put the pairs of words in a list (each element is a pair for a Japenese word and its English translation), shuffle the list, then iterate through the list to display them.

I hope this makes sense and helps a little bit.

Code-Apprentice
  • 81,660
  • 23
  • 145
  • 268