Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Amg = input()
amgo = Amg[1]
amg = Amg[0]
mg = input()
k = mg[1]
ks = mg[0]
minus = amgo - k
minus2 = amg - ks
total = minus + minus2
print(total)


What I have tried:

i have tried google and have tried fixing the error myself but no work
(sorry for bad english i am portuguese)
Posted
Updated 7-Mar-22 21:34pm

You are trying to do calculations on strings instead of integer values. You need something like:
Python
number1 = int(input("Enter first number: "))
number2 = int(input("Enter second number: "))
operator = input("Enter math operator: ")
sum = 0
if operator == '+':
    sum = number1 + number2
elif operator == '-':
    sum = number1 - number2
#
# other operator code here
#

print("The sum is:", sum)

See The Python Tutorial — Python 3.9.10 documentation[^] for more information.
 
Share this answer
 
Comments
Maciej Los 8-Mar-22 12:25pm    
5ed!
Richard MacCutchan 8-Mar-22 12:40pm    
Thanks.
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with - we get no other context for your project.
Imagine this: you go for a drive in the country, but you have a problem with the car. You call the garage, say "it broke" and turn off your phone. How long will you be waiting before the garage arrives with the right bits and tools to fix the car given they don't know what make or model it is, who you are, what happened when it all went wrong, or even where you are?

That's what you've done here. So stop typing as little as possible and try explaining things to people who have no way to access your project!

We have no idea what that code is supposed to do, and no idea what values you feed to it - so we can't help you fix that!

So, it's going to be up to you.
Fortunately, you have a tool available to you which will help you find out what is going on: the debugger. Start here: pdb — The Python Debugger — Python 3.10.2 documentation[^] and it'll give you the basics of using it.

Put a breakpoint on the first line in the function, and run your code through the debugger. Then look at your code, and at your data and work out what should happen manually. Then single step each line checking that what you expected to happen is exactly what did. When it isn't, that's when you have a problem, and you can back-track (or run it again and look more closely) to find out why.

Sorry, but we can't do that for you - time for you to learn a new (and very, very useful) skill: debugging!


Google translate:
Esta não é uma boa pergunta - não podemos deduzir desse pouco o que você está tentando fazer.
Lembre-se de que não podemos ver sua tela, acessar seu HDD ou ler sua mente - só obtemos exatamente o que você digita para trabalhar - não obtemos nenhum outro contexto para seu projeto.
Imagine isso: você vai dar uma volta no campo, mas tem um problema com o carro. Você liga para a garagem, diz "quebrou" e desliga o telefone. Quanto tempo você vai esperar até que a garagem chegue com as peças e ferramentas certas para consertar o carro, já que eles não sabem qual é a marca ou modelo, quem você é, o que aconteceu quando tudo deu errado ou mesmo onde você está? ?

Isso é o que você fez aqui. Então pare de digitar o mínimo possível e tente explicar as coisas para pessoas que não têm como acessar seu projeto!

Não temos ideia do que esse código deve fazer, e não temos ideia de quais valores você alimenta a ele - então não podemos ajudá-lo a corrigir isso!

Então, vai depender de você.
Felizmente, você tem uma ferramenta disponível que o ajudará a descobrir o que está acontecendo: o depurador. Comece aqui: pdb — The Python Debugger — documentação do Python 3.10.2[^] e fornecerá o básico de como usá-lo.

Coloque um ponto de interrupção na primeira linha da função e execute seu código pelo depurador. Em seguida, observe seu código e seus dados e descubra o que deve acontecer manualmente. Em seguida, dê um único passo em cada linha, verificando se o que você esperava que acontecesse é exatamente o que aconteceu. Quando não é, é aí que você tem um problema, e você pode voltar atrás (ou executá-lo novamente e olhar mais de perto) para descobrir o porquê.

Desculpe, mas não podemos fazer isso por você - é hora de você aprender uma nova (e muito, muito útil) habilidade: depuração!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900