What's Wrong Here?


#1

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:
break
print “stop it”


FAQ: Learn Python- Loops - Break
#2

what data type is A?

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

https://www.python.org/dev/peps/pep-0008/

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


#3

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


#4

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.


#5

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


#6

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