I have a function in Python that returns the initialized value of the value I want to return instead of going into the if-else to find the right number to print. Here is my code:
def getCell(x, y):
answer = -1
if y <= 16666666.6667:
if x <= 16666666.6667:
answer = 0
elif x <= 33333333.3333:
answer = 1
elif x <= 50000000.0:
answer = 2
elif x <= 66666666.6667:
answer = 3
elif x <= 83333333.3333:
answer = 4
elif x <= 100000000.0:
answer = 5
elif y <= 33333333.3333:
if x <= 16666666.6667:
answer = 6
elif x <= 33333333.3333:
answer = 7
elif x <= 50000000.0:
answer = 8
elif x <= 66666666.6667:
answer = 9
elif x <= 83333333.3333:
answer = 10
elif x <= 100000000.0:
answer = 11
elif y <= 50000000.0:
if x <= 16666666.6667:
answer = 12
elif x <= 33333333.3333:
answer = 13
elif x <= 50000000.0:
answer = 14
elif x <= 66666666.6667:
answer = 15
elif x <= 83333333.3333:
answer = 16
elif x <= 100000000.0:
answer = 17
elif y <= 66666666.6667:
if x <= 16666666.6667:
answer = 18
elif x <= 33333333.3333:
answer = 19
elif x <= 50000000.0:
answer = 20
elif x <= 66666666.6667:
answer = 21
elif x <= 83333333.3333:
answer = 22
elif x <= 100000000.0:
answer = 23
elif y <= 83333333.3333:
if x <= 16666666.6667:
answer = 24
elif x <= 33333333.3333:
answer = 25
elif x <= 50000000.0:
answer = 26
elif x <= 66666666.6667:
answer = 27
elif x <= 83333333.3333:
answer = 28
elif x <= 100000000.0:
answer = 29
elif y <= 100000000.0:
if x <= 16666666.6667:
answer = 30
elif x <= 33333333.3333:
answer = 31
elif x <= 50000000.0:
answer = 32
elif x <= 66666666.6667:
answer = 33
elif x <= 83333333.3333:
answer = 34
elif x <= 100000000.0:
answer = 35
return answer
I have tried many different combinations of x & y, but it always returns -1. Why? I used this exact code in another program and it worked there.
These are the values that the other program with the same code put these x & y values:
x = 21659939 y = 42211657 put into cell 13
x = 30336851 y = 58758061 put into cell 19
Thank you.
Aucun commentaire:
Enregistrer un commentaire