'useranswer' が 'correctanswer' の場合、ループが正しく機能せず、等しい場合でも等しくないと述べている場合、python クイズ プログラムを機能させることができません。これはリストに保存された文字列を比較する際の問題なのだろうかと思っていますが、どうすれば修正できるのか本当に困っています。どんな助けでも大歓迎です。
ありがとうございました
import sys
print ("Game started")
questions = ["What does RAD stand for?",
"Why is RAD faster than other development methods?",
"Name one of the 3 requirements for a user friendly system",
"What is an efficient design?",
"What is the definition of a validation method?"]
answers = ["A - Random Applications Development, B - Recently Available Diskspace, C - Rapid Applications Development",
"A - Prototyping is faster than creating a finished product, B - Through the use of CASE tools, C - As end user evaluates before the dev team",
"A - Efficient design, B - Intonated design, C - Aesthetic design",
"A - One which makes best use of available facilities, B - One which allows the user to input data accurately, C - One which the end user is comfortable with",
"A - A rejection of data which occurs because input breaks predetermined criteria, B - A double entry of data to ensure it is accurate, C - An adaption to cope with a change external to the system"]
correctanswers = ["C", "B", "A", "A", "A"]
score = 0
lives = 4
z = 0
for i in range(len(questions)):
if lives > 0:
print (questions[z])
print (answers[z])
useranswer = (input("Please enter the correct answer's letter here: "))
correctanswer = correctanswers[z]
if (useranswer) is (correctanswer): //line im guessing the problem occurs on
print("Correct, well done!")
score = score + 1
else:
print("Incorrect, sorry. The correct answer was; " + correctanswer)
lives = lives - 1
print("You have, " + str(lives) + " lives remaining")
z = z + 1
else:
print("End of game, no lives remaining")
sys.exit()
print("Well done, you scored" + int(score) + "//" + int(len(questions)))