I've written a number guessing game in Python 2.7.14 and encountered something odd:
I ask for an integer as input and check for that, but the name of the variable (here "a") is always accepted, although no other strings or characters are accepted. Isn't this an issue when the user can enter variable names even though they are not allowed?
My code is:
from random import randint
a = randint(0,10)
b = input("enter a number between 0 and 10 ")
print "you entered :", b
if type(b) != int:
print "please enter only integers"
else:
if b < a:
print "b is smaller than a"
elif b == a:
print "b is equal to a"
else:
print "b is NOT smaller than a"
print "number was", a