'Python not equal to 0

I am new to Python. How can I know if a function is being used or not; if it is not equal to zero then the program will print; otherwise, do not print any zero.



Solution 1:[1]

You are almost there... but you need to use != and : in your if statement

Using the 'if' statement :-

            b1 = (int(a1[0]) + int(a2[0])) // 10
            if b1!=0:
              print(b1)

Solution 2:[2]

use != for condition check

b1 = (int(a1[0]) + int(a2[0])) // 10

if b1 != 0:

    print (b1)

Solution 3:[3]

You can even do not use != to check "not equality" with 0

v = 0
if v: # instead of v!=0
   print ("Invisible")

v = 100
if v: # instead of v!=0
   print ("Visible")

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Soumithri Chilakamarri
Solution 2 Aneesh Jose
Solution 3 Ali Ye?ilkanat