[Tutor] Instead of *.TXT I would like to use *.CSV exported from Excel
Mario Py
mariopy at gmx.com
Fri Jul 4 03:07:51 CEST 2014
OK, I'm finally getting closer.
Code bellow (looks like) works if I comment out shuffle part
But I need it to shuffle so I get random picked words.
How do I get shuffle part to work?
from random import shuffle
import csv
print('Write translation of Slovene word ')
print()
out=open('c:\\prevedi.csv', 'r', newline='', encoding='utf8')
data=csv.reader(out)
# shuffle(data)
for line in data:
question, rightAnswer = line
answer = input(question + ' ')
if answer.lower() != rightAnswer:
print('Correct is: %s.' % rightAnswer,)
print()
More information about the Tutor
mailing list