Python 这个代码需要更正。I';我无法在此程序中运行elif部件

Python 这个代码需要更正。I';我无法在此程序中运行elif部件,python,Python,我无法访问elif部件: total = input('What is the total amount for your online shopping?') country = input('Shipping within the US or Canada?') if country == "US": if total <= "50": print("Shipping Costs $6.00") elif total <= "100":

我无法访问
elif
部件:

total = input('What is the total amount for your online shopping?')
country = input('Shipping within the US or Canada?')

if country == "US":
    if total <= "50":
        print("Shipping Costs $6.00")
    elif total <= "100":
        print("Shipping Costs $9.00")
    elif total <= "150":
        print("Shipping Costs $12.00")

    else:
        print("FREE")

if country == "Canada":
    if total <= "50":
        print("Shipping Costs $8.00")
    elif total <= "100":
        print("Shipping Costs $12.00")
    elif total <= "150":
        print("Shipping Costs $15.00")
    else:
        print("FREE")
total=input('您网上购物的总金额是多少?')
国家=输入(“在美国或加拿大境内运输”)
如果国家=“美国”:
如果total实际上,您可以使用int(“50”)将“50”从字符串转换为整数50

total = input('What is the total amount for your online shopping?')
python输入默认为字符串数据类型。您必须转换为int才能进行比较

total = int(input('What is the total amount for your online shopping?'))
更新工作代码:

total = int(input('What is the total amount for your online shopping?'))
country = input('Shipping within the US or Canada?')

if country == "US":
    if total <= 50:
        print("Shipping Costs $6.00")
    elif total <= 100:
        print("Shipping Costs $9.00")
    elif total <= 150:
        print("Shipping Costs $12.00")

    else:
        print("FREE")

if country == "Canada":
    if total <= 50:
        print("Shipping Costs $8.00")
    elif total <= 100:
        print("Shipping Costs $12.00")
    elif total <= 150:
        print("Shipping Costs $15.00")
    else:
        print("FREE")
total=int(输入('网上购物的总金额是多少?'))
国家=输入(“在美国或加拿大境内运输”)
如果国家=“美国”:

如果total您正在比较字符串。使用
total=int(input(…)
将输入更改为整数,并将其与数字而不是字符串进行比较:
如果total您在比较整数时比较字符串,则表示您在比较
ASCII
值。
请参见以下代码段:

total = "120"
if total <= "50":
    print("yes")
total=“120”
if total if total这里的“50”是字符串。改为总数