On 04/07/2014 06:44, Mitesh H. Budhabhatti wrote:
Hello Mario,
I think if you are facing the problem with shuffle, can the below
solution help:
import random
import csv
f = open('D:\\py.csv', 'r', newline='', encoding='utf8')
csvreader = csv.reader(f)
l = [row for row in csvreader] #we get rows in the file as a list
using list comprehension
random.shuffle(l)
Thanks
Warm Regards,
Mitesh H. Budhabhatti
Cell# +91 99040 83855
On Fri, Jul 4, 2014 at 6:37 AM, Mario Py <mari...@gmx.com
<mailto:mari...@gmx.com>> wrote:
>
> 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()
>
I appreciate you trying to help out, but please don't top post on this
list, it makes following longer threads very difficult, thanks .
Slight aside, it appears from "cell#" that you're in prison. Is that
the case, or did you actually mean "mobile phone number"? :)
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
---
This email is free from viruses and malware because avast! Antivirus protection
is active.
http://www.avast.com
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor