私は現在、クイズに取り組んでいます。誰もが私が受け続けるエラーで私を助けることができるかどうか私はさまよっていた。私はそれがランダムな順序で質問をし、それらを他の質問の答えと質問を与えて保持しないようにそれを作るしようとしているリストを別のリストでランダム化する
num1 = num = 0
import random
questions = ["What is RAM?","what is ROM","What is a bundle of wires
carrying data from one component to another?","What does the control unit
do?"]
ans = [["Random access memory","real access memory","read access
memory","readable access memory","A"],["Readable object memory","Random
object memory","Read only memory","Read object memory","C"],
["Bus","Hardware","System software","Embedded systems","A"],["You type on
it","It sends out control signals to other components","It calculates
arithmetic problems","Regulates time and speed of computer functions","D"]]
for index in range(0, len(questions)):
val = [0, 1, 2, 3]
index = random.choice(val)
print(questions[index])
print("\nA:",ans[index][0],"\nB:",ans[index][1],"\nC:",ans[index]
[2],"\nD:",ans[index][3],"")
pa = input("What is your answer?")
if pa == ans[index][4]:
num1, num = num1 + 1, num + 1
print("Correct!\nYou have got",num1,"out of",num,"correct so far\n")
questions.remove(questions[index])
ans.remove(ans[index])
val.remove(index)
else:
num = num + 1
print("incorrect!\nThe correct answer was",ans[index][4],"Your
correct questions are Your incorrect questions are")
:ここに私のコードです。誰でもそれがどうやって行えるか知っていますか? 助けていただければ幸いです。インデックスの
はい、それは 'questions.remove(question)'を読むべきです – Will
ありがとう!:) – johnnu