Advertisement
Razzim

python quiz lab4

Dec 4th, 2017
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. #import csv
  2.  
  3. #data = []
  4. #with open('pytania.txt', newline='') as inputfile:
  5. # for row in csv.reader(inputfile):
  6. # if row.find('\question'):
  7. # data.append(row)
  8.  
  9. pytania = []
  10. tempPyt = []
  11. odpowiedzi = []
  12. tempOdp = []
  13. que = False
  14. nr = 0
  15. with open('pytania.txt') as inputfile:
  16. for line in inputfile:
  17. if line.find('\question')!=-1:
  18. tempPyt.append(line.strip().split(','))
  19. if line.find('\Eanswer')!=-1:
  20. que = False
  21. odpowiedzi.append(tempOdp)
  22. tempOdp = []
  23. if que:
  24. if line.find('\ca')!=-1:
  25. tempPyt.append(nr)
  26. tempOdp.append(line.strip('\ca').split(','))
  27. else:
  28. tempOdp.append(line.strip('\ica').split(','))
  29. nr=nr+1
  30.  
  31. if line.find('\Banswer')!=-1:
  32. que = True
  33. nr = 0
  34.  
  35.  
  36. #print(pytania)
  37. print(odpowiedzi)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement