How to write "not equal" in python?

0 votes

What is the replacement for == or how to write "not equal" in the following example:

if hello == hello:
    print "hello"
elif hello (does not equal) goodbye:
    print "no hello"
Sep 17, 2018 in Python by ana1504.k
• 7,870 points
127 views

1 answer to this question.

0 votes

The keywords is and is not are used for comparing objects. you can use  != as a replacement for "not equal".

For example :

10 == 10 #  -> True
10 != 10 #  -> False
a = b = []; a is b # -> True (same object)
answered Sep 17, 2018 by SayantiniDeb
• 200 points

Related Questions In Python

0 votes
1 answer

How to use not equal operator in python

Use !=. See comparison operators. For comparing object identities, ...READ MORE

answered Dec 20, 2018 in Python by charlie_brown
• 7,720 points
147 views
0 votes
0 answers

How to mix read() and write() on Python files in Windows

It appears that a write() immediately following a read() on a ...READ MORE

Oct 23, 2018 in Python by Aryya
• 500 points
53 views
0 votes
1 answer

How to write to CSV line by line in python

The simple way of doing this will ...READ MORE

answered Nov 15, 2018 in Python by findingbugs
• 3,170 points
423 views
0 votes
1 answer

How to write inline if statement for print in Python?

Inline if-else expression must always contain the else ...READ MORE

answered Dec 4, 2018 in Python by Nymeria
• 3,520 points

edited Dec 6, 2018 by Nymeria 1,231 views
0 votes
1 answer
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 329 views
0 votes
1 answer

__init__ and self in python

The self variable represents an instance of ...READ MORE

answered Sep 17, 2018 in Python by SayantiniDeb
• 200 points
47 views