Answer the question
In order to leave comments, you need to log in
How to make if the number was not an integer, gave out -1 in response?
def get_row_len(row, col, cell_index):
if (cell_index / row) - col == float:
return -1
Answer the question
In order to leave comments, you need to log in
These are exactly the application settings, it may be worth adding domains like site.ru and www.site.ru or any other domains if used
or recreate it
You are comparing some number with a type, nothing bothers you?
def get_row_len(row, col, cell_index):
A = (cell_index / row) - col
if round(A) != A:
return -1
is_float = lambda x: bool(x % 1 )
def get_row_len(row, col, cell_index):
if is_float(cell_index / row - col):
return -1
def get_row_len(row, col, cell_index):
if (cell_index / row - col) % 1:
return -1
def get_row_len(row, col, cell_index):
a = (cell_index / row) - col
if int(a) != a:
return -1
def get_row_len(row, col, cell_index):
if type((cell_index / row) - col)) == float:
return -1
//////////
isinstance(1.1, float)
>>> True
is_integer() method
a = (cell_index / row) - col
if a.is_integer():
return a
else:
return -1
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question