出现错误“原因:无法确定颜色类型。类型不匹配:无法用 str 替换 Call”

问题描述 投票:0回答:1

我有一项任务是为标志创建成本。我已经完成了作业的所有工作,代码甚至按照它想要的方式完美运行。但是,它一直给我错误“原因:无法确定颜色类型。类型不匹配:无法用 str 替换 Call”。

这是我的代码。效果很好。例如,它希望带有 8 个字母和松木的金色文本标志的价格为 62 美元,这是程序结束时的最终价格。

# Initialize variables here.
charge = 0
num_chars = 8
color = "gold"
wood_type = "oak"
minChars = 5
costChars = 4

# Charge for this sign.

# Number of characters.
print("The first five letters are included in the minimum charge, but each individual character afterwards is an additional 4$")
num_chars = int(input("Enter how many characters you will have on the sign: "))
if num_chars > minChars:
    charge = (num_chars - minChars) * costChars
# Color of characters.
color = input("Do you wan to pay 15$ additional for gold lettering or black and white: ")
if color == "gold":
    charge = charge + 15
elif color == "black and white":
    charge
# Type of wood.
wood_type = input("Do you wan to pay 20$ additional oak or pine: ")
if wood_type == "oak":
    charge = charge + 20
elif wood_type == "pine":
    charge
# Write assignment and if statements here as appropriate.

# Output Charge for this sign.
charge = charge + 35
print(f"The charge for this sign is ${charge:.2f}")`

这是包含错误的输出:

Status: FAILED!
Check: 1
Test: Black and white, 5 letter, on pine (minimum charge).
Reason: Unable to determine color type. Type mismatch: Cannot replace Call with str.
Error : ValueError - Unable to determine color type. Type mismatch: Cannot replace Call with str.
Timestamp: 2024-04-27 20:20:03.443145

Status: FAILED!
Check: 2
Test: Gold leaf, 10 letter, on oak.
Reason: Unable to determine color type. Type mismatch: Cannot replace Call with str.
Error : ValueError - Unable to determine color type. Type mismatch: Cannot replace Call with str.
Timestamp: 2024-04-27 20:20:03.443463

Status: FAILED!
Check: 3
Test: Gold leaf, 8 letter, on pine.
Reason: Unable to determine color type. Type mismatch: Cannot replace Call with str.
Error : ValueError - Unable to determine color type. Type mismatch: Cannot replace Call with str.
Timestamp: 2024-04-27 20:20:03.443735

这是作业:作业

这是给出的代码:原始代码

python string call type-mismatch
1个回答
0
投票

我在 COP 1000 中也遇到了同样的错误。我摆脱了用户输入并运行了它。我删除输入后没有任何错误代码。

© www.soinside.com 2019 - 2024. All rights reserved.