Hi, everyone whom might read this, im Max and i am really new to coding,
been going at it for about two weeks using codeacademy and the book "think
python".
when i decided to experiment a little with if statements i ran into the
following problem:
def plus(x,y):
if x and y == int or float:
print "The answer is: " + str(x+y)
else:
print "not a number"
plus(2,2)
plus("one","two")
concatenates one and two insted of printing "not a number"
i have tried to simplify by not cheacking for float values an i have also
tried.
def plus(x,y):
if x and y == int or float:
print "The answer is: " + str(x+y)
elif x or y != int or float:
print "not a number"
Am i perhaps missing something with the logic gates?
Any help is greatly appreciated !
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor