I'm trying to write a program in Python to tell me one thing if the inputed number is between 1 and 100. This is the code I have so far:
number = int (raw_input ("give me a number."))
if number < 100 and number > 1:
print ("Great! The number " + number + " is in fact between 1 and 100. I am happy " + number + " times")
if number < 1 or number < 100:
print ("Not so great! The number " + number + " is not between 1 and 100.")
I can run the first bit, but once I input a number that is between 1 and 100, I keep getting this error:
Traceback (most recent call last):
File "/Downloads/number (1).py", line 3, in <module>
print "Great! " + number + " is in fact between 1 and 100"
TypeError: cannot concatenate 'str' and 'int' objects
How can I fix this?
if 1 <= number <= 100:andelse:as it is right now thenumber100and1are not caughtnumber > 1 or number < 100always evaluate to True? Name a number that is both less than one and greater than a hundred ;-)NaN.