I have two text files, students
and questions
. In students
are students and in questions
are questions. Each student corresponds to one question, but sometimes questions are the same and I want to not repeat questions.
import random
k = int(input("how many questions do you want ? -"))
questions1 = open("question.txt",'r')
studenti = open("students.txt",'r')
splited = questions1.read().split('\n')
splitedstud = student1.read().split('\n')
for studens in splitedstud:
file = open(studens + ".txt", "w")
for i in range(int(k)):
questiion = random.choice(splited)
file.write(questiion + '\n')
file1 = open(studens + ".txt", "r")
f = file1.read()
if questiion in f:
continue
file.close()
questions.close()
students.close()
splited
either, and I somehow doubt studens is the intended meaning.