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,900 points
1,015 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
3 answers

How to use not equal operator in python

We can use Python not equal operator ...READ MORE

answered Dec 9, 2020 in Python by Niroj
• 82,720 points
132,780 views
0 votes
2 answers

How to use in python for loop not equal marks? example: a!=0

Hello @Azizjon, You can go through the example ...READ MORE

answered Oct 12, 2020 in Python by Gitika
• 65,870 points
360 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
217 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,260 points
3,757 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 12,755 views
0 votes
2 answers
+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, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 2,035 views
0 votes
0 answers
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
148 views