i am new to programming. According to my book, this code should get an error.
>>> age = input("How old are you? ")
How old are you? 21
>>> age >= 18
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
vTypeError: unorderable types: str() >= int()
In Sublime i saved a .py file:This is my .py file.
Then , in the terminal when i tried running it. It did not give me an error. First time , i ran it by entering the age 21 without the quots , it returned True. Then , i entered 17 , it returned False.
Firstly , How does my computer know that they are integers? I did not enter age=int(age).
Secondly when i input "21", its returning True. No error. Why is that happening?
How is it comparing a string and an integer?
and when i input "17" as my age, it returned True again . **Why is that happening?
It is not only comparing a sting and an integer but giving the wrong answer also this time.**