What's Wrong Here?


Do I write something wrong here?

A = raw_input("Hi, type a positive number: ")
while A >= 0:
A = raw_input(“Cool, do it again”)
if A <= 0:
print “stop it”

FAQ: Learn Python- Loops - Break

what data type is A?

i would also give your variable logic names and follow python recommendations:


for naming variable. uppercase letters for variable names is really unusual in python


A is a random variable.
The whole code is not working well for me! I dont know why!


I think what @stetim94 is hinting at is the data type returned from the raw_input() function. It is a string, not a number.

Python variables take their type from the values assigned to them.


So, if I add INT before A would it be flawless?


Yes, either cast A to an integer before calling it, or cast the input return. Either will be valid.