title: randomising the display of fields in a row from file in python
body: <p>I have the following file structure 
  <strong>File structure</strong></p>
  
  <pre><code>1?,a,b,c,d,1
  2?,a,b,c,d,2
  3?,a,b,c,d,3
  4?,a,b,c,d,4
  5?,a,b,c,d,5
  </code></pre>
  
  <p><strong>The code</strong> I have is as follows:</p>
  
  <pre><code>def myfunction(dr):
    print("===H===")
    print("You have selected rating: ", dr)
    question_count=0
    while question_count&lt;5:
      with open('myfile.txt','r') as f:
          reader=csv.reader(f,delimiter=",")
          answer=False
          while answer==False:
  
             for row in reader:
  
              if dr=="d": 
  
                c_a=int(row[6])
  
                print(row[0])
                print(row[c_a])
                print(row[2])
                print(row[3])
                print(row[4])
  
  
              elif dr =="m":
  
                correct_answer=int(row[6])
  
                print(row[0])
                print(row[c_a])
                print(row[2])
                print(row[3])
  
              elif dr=="e": 
                 correct_answer=int(row[6])
  
                 print(row[0])
                 print(row[c_a])
                 print(row[2])
  </code></pre>
  
  <p>At the moment, the program reads the file, inserts the right answer into the mix, but what I want it to do is:</p>
  
  <p>insert the correct variable into the mix</p>
  
  <p>I will need some help with randomisation within this file handling structure, and how to not duplicate the correct answer. </p>
  
  <p>I did think about reading all into a list, and then producing a random output, but it seemed terribly complex. Is there an easier way?</p>
  
  <p>Update:</p>
  
  <p>One suggestion is to use a different file format, but I want to, if at all possible avoid that, although please feel free to make these suggestions in your answers:</p>
  
  <p>My other idea was to create a list: Search for duplicates in that list, and then delete the duplicate, if any, from that list. </p>
  
  <p>I have this so far, it doesn't work quite yet and nor does it include randomisation of the resultant list:</p>