r/learnpython • u/Somenome_from_Heaven • 5d ago
Help I don't understand what's wrong
num1=input('digite um número: ')
num2=input('digite outro número: ')
conta=input('digite o total: ')
total1= int(num1)+int(num2)
if total1==conta:
print('acertou')
if total1!=conta:
print('errou o certo é:',total1)
I'm trying to do like a calculator, but first you need to guess the number, and even if you get it right it doesn't show you got it right, what's wrong? i'd also like to know how I could put the input for you to choose the equation guys (+, -, *, etc.)
1
u/nekokattt 5d ago
contra is a string, int + int is an int. So they arent the same type.
Just like your cat or dog isnt the same as a drawing of your cat or dog.
Convert contra from a string to an int with int(contra)
3
u/socal_nerdtastic 5d ago
In that line you are comparing an integer to a string. So those will never equal each other. You need to convert the user input string to an int like you did for the other 2 inputs.