-2
我對python相當陌生,我想知道是否有人能夠幫助我循環這段代碼,並且我在過去做了循環,但是這個循環包含一個list元素不得不每次改變1次到10次,我不知道如何做出改變。我該如何循環一個涉及列表的代碼
print ("Question 1: ")
print (questions[0])
#asks for the answer from the user
ans = int(input())
#compares the users input to the answer
if ans == eval(questions[0]):
print ("Well done, you got it correct")
#if correct grants a point to the overall score
score = score + 1
「不安全」是什麼意思? – 2014-11-20 17:28:43
請參閱[這裏](http://stackoverflow.com/questions/1832940/is-using-eval-in-python-a-bad-practice)例如,也[這裏](http://nedbatchelder.com /blog/201206/eval_really_is_dangerous.html)。 – CoryKramer 2014-11-20 17:29:28
但如果我使用它爲一個簡單的程序,不是太複雜,我應該沒事吧?或者在可能嘗試擴展時遇到問題? – 2014-11-20 17:32:44