python不能分配给操作员_Python无法分配op

我是python新手,不到一周前就开始编写代码了。我决定尝试建立一个单独的diget计算器。我知道我的代码可能写得不是很好,建议很感激,但请不要只是讨厌它。好了,现在来看看代码。我得到的错误代码说,它不能分配一个Operator。我知道这意味着它不能把变量变成from string to int,但我不知道如何修复它。我在第25、28、31、34行得到了错误。谢谢!在calculate = input("Enter the problem in the format x + y = z ")

opperations = ["+", "-", "*", "/"]

numbers = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]

space = " "

def opperation():

if opperations == "+":

A = 1

elif opperations == "-":

A = 2

elif opperations == "*":

A = 3

elif opperations == "/":

A = 4

if calculate[0] in numbers:

if len(calculate) > 1:

if calculate[1] == space:

calculate[0] = a

a = int(a)

calculate[4] = b

b = int(b)

if A == 1:

a + b = c

print (c)

elif A == 2:

a - b = c

print (c)

elif A == 3:

a * b = c

print(c)

elif A == 4:

a / b = c

print(c)

else:

print("Sorry invalid text")

else:

print("Sorry invalid text")

else:

print("Sorry invalid text")

else:

print("Sorry invalid text")

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值