No matter what I do, I can’t get this while loop to work; unless i hardcode the value in.
count = 0
value = raw_input('How many?')
print value
while (count <= value):
print "a"
count= count + 1
At first I tried using a command line argument, using sys.argv[1] for value but I got the same problem. This seems so simple, yet I cannot for the life of me figure out what I’m doing wrong.
Ensure that value is an integer,
By default
raw_inputis a string, and for every integernand every stringswe haven<s is True(!), hence your loop (without theint) never breaks.Note: In Python 3 comparing string and integers will give a
TypeError: unorderable types: str() < int(), which is probably more “expected” behaviour.