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,910 points
2,398 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 18, 2018 by SayantiniDeb
• 200 points

Related Questions In Python

+1 vote
7 answers

How to use not equal operator in python

To check if operands are not equal ...READ MORE

answered Nov 30, 2021 in Python by Charry
370,945 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,770 points
2,258 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 24, 2018 in Python by Aryya
• 500 points
811 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
5,646 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,560 points

edited Dec 6, 2018 by Nymeria 16,744 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 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,414 views
0 votes
1 answer
0 votes
1 answer

__init__ and self in python

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

answered Sep 18, 2018 in Python by SayantiniDeb
• 200 points
944 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP