In the second line you are converting the contents of the variable idade
for whole and discarding the result, then when you check you think it is already a whole, but it is still a string. I imagine you wanted to store this somewhere. And I imagine you think just doing the operation on the variable changes her value, but it doesn’t, you just manipulate her value.
But the correct thing would be to create another variable since they are different types. And the error caused shows why it is better not reuse variable with different types. In Python it would work to play in the same variable, but it’s not nice to do this. The good part is that you don’t even have to do this, you can read the data and convert at once and only save the converted value, like this:
idade = int(input("Qual a sua idade? "))
if idade >= 45:
print("Tá velho cara, já era!")
else:
print("A vida está só começando rapaz!")
Behold working in the ideone. And in the repl it.. Also put on the Github for future reference.
This code can still fail, it can be written differently, but basically, to start learning, this is it.
Did any of the answers solve your question? Do you think you can accept one of them? Check out the [tour] how to do this, if you haven’t already. You would help the community by identifying what was the best solution for you. You can accept only one of them. But you can vote on any question or answer you find useful on the entire site.
– Maniero