Home > Software design >  How to verify if my condition is True or False in a Big check of all conditions?
How to verify if my condition is True or False in a Big check of all conditions?

Time:09-16

How can I check if my 'check' condition returns 'True' or not?

I want to check if my two conditions satisfies or not. I have written below code but gives error.

#---------------------------CONDITION: 2------------------------------------------------#

check = all(item in new_coordi2 for item in new_coordi1)
if check:
    print("Contains all coordinates")
else:
    print("Does not contain all coordinates")

#---------------------------Checking of all two conditions-----------------------------#

# ALl theree conditions must be fulfilled in order to conclude the 'similar geometry'.
# If number of nodes in both geometries are same, if distance between two consecutive nodes are same and distances between first node to each node in geometies are same. then only 'Similar geometries' can be concluded.

if (len(node_number2) == len(node_number1) and (check is True):
    print('All three conditions are satisfied.')
    print('Hence Yes, two geometries are same.')
else:
    print('No, two geometries are not same.')

Error:

enter image description here

How can I fix this?

CodePudding user response:

You missed a parenthesis and you can convert check is True to simply : check (since it's value is True or False)

#---------------------------CONDITION: 2------------------------------------------------#
      
check = all(item in new_coordi2 for item in new_coordi1)
if check:
    print("Contains all coordinates")
else:
    print("Does not contain all coordinates")

#---------------------------Checking of all two conditions-----------------------------#

# ALl theree conditions must be fulfilled in order to conclude the 'similar geometry'.
# If number of nodes in both geometries are same, if distance between two consecutive nodes are same and distances between first node to each node in geometies are same. then only 'Similar geometries' can be concluded.

if (len(node_number2) == len(node_number1)) and check:
    print('All three conditions are satisfied.')
    print('Hence Yes, two geometries are same.')
else:
    print('No, two geometries are not same.')
  • Related