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
• 6,110 points
40 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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,710 points
61 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
23 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,140 points
77 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,500 points

edited Dec 6, 2018 by Nymeria 480 views
0 votes
1 answer
0 votes
1 answer

how can i count the items in a list?

suppose you have a list a = [0,1,2,3,4,5,6,7,8,9,10] now ...READ MORE

answered May 2 in Python by Mohammad
• 1,400 points
25 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
18 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.