I leaned C of the last summer from K&R book from 1989. I am now learning python3.
I am a little confused about something.
In C if i do a test
if !(.....) The '!' changes the value in the '( )' to the opposite, so if it was true, it becomes false and vis versa.
So what i was trying to do, is change this from C to python.
int card(long long number, int size){
if(!(size == 13 || size == 15 || size == 16)) { // test to see if valid size.
printf("INVALID\n");
return 0;
}
When i tried
def card(number, size):
if !(size == 13 or size == 15 or size == 16):
print("INVALID")
return 0
I got a syntax error.
So after searching on-line I found "is not" in the python3 doc.
so i try it on the interactive terminal.
>>> if is not (size == 13 or size == 15 or size == 16):
File "<stdin>", line 1
if is not (size == 13 or size == 15 or size == 16):
^
The interpreter was saying the 'is' is a syntax error. So i decided to remove it and see what happens. And it worked!
I searched on-line and i do not find the 'not' without the 'is'?
Is it OK to use 'if not ( ......)' as the equivalent of 'if !(......)' in C? Or will i get into problems? Or is there a different python way of doing this?