我的项目的目标是使用决策块找到确切的更改。我的所有代码都返回了正确的答案,但答案是“没有变化”。
该解决方案按预期显示为“无更改”,但随后显示错误代码
create_table "users", force: :cascade do |t|
t.string "type", null: false
t.string "login", limit: 40, null: false
t.string "password", limit: 500, null: false
t.bigint "company_id"
t.index ["company_id"], name: "index_users_on_company_id"
t.index ["login"], name: "index_users_on_login", unique: true
end
create_table "experiences", force: :cascade do |t|
t.string "job_name", limit: 100, null: false
t.bigint "company_id"
t.bigint "user_id", null: false
t.text "description"
t.index ["company_id"], name: "index_experiences_on_company_id"
t.index ["job_name"], name: "index_experiences_on_job_name"
t.index ["user_id"], name: "index_experiences_on_user_id"
end
add_foreign_key "users", "companies"
add_foreign_key "experiences", "companies"
add_foreign_key "experiences", "users"
有人知道为什么会这样吗?我的代码如下。
Traceback (most recent call last):
File "main.py", line 21, in <module>
if dollars == 1:
NameError: name 'dollars' is not defined
答案 0 :(得分:0)
您需要在使用变量之前声明它们。
在您的代码中,draw
块之外的变量dollars, quarters, dimes, nickels, pennies
不可见
else