0
當我運行下面的代碼時,出現以下錯誤:eval()arg 1必須是字符串或代碼對象必須是一個字符串或代碼對象嗎?
任何人都知道爲什麼?這是我從書中學到的代碼,所以我認爲這是正確的。
# Prompt the user to enter three numbers
number1 = eval(input("Enter the first number: "))
number2 = eval(input("Enter the second number: "))
number3 = eval(input("Enter the third number: "))
# Compute average
average = (number1 + number2 + number3)/3
print("The average of", number1, number2, number3, "is", average)