Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Checking for equality
#1
Guys,I know this is so kindergarten, but I just can't find the answer.

So according to my textbook to check for equality in a simple example, all I need is:

car="bmw"
car=="bmw"
and this should give me TRUE or FALSE, yet I get no output at all.

Thanks and I know this is ridiculously basic.
Reply
#2
it depends if you are running in interactive mode e.g.
>>> car = 'BMW'
>>> car == 'BMW'
True
>>> car == 'Renault'
False
if you are not in interactive mode, you need to print in order to see the result, e.g. in yourfile.py:
car = 'BMW'
print(car == 'BMW')
print(car == 'Renault')
Output:
True False
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
Thanks Buran,

unfortunately, this brings me to the next problem, how do I get into interactive mode? Searching the web, I keep getting the advice to simply type "python" or "python 3". This doesn't work.

Using Spyder (Python 3.7) on windows ffiw.
Reply
#4
you should write python or python3 in command prompt, not in Spyder IDE.
I never used Spyder, so it's possible it has integrated terminal, but as I never used it I cannot be sure/don't know.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#5
Did you look at the docs for Spyder? It seems to have an IPython console.
Reply
#6
I've typed "python" and "python3" into the command promt and the console. Doesn't do anything unfortunately.
Reply
#7
Here's what I found, if you use the following code:

import code
code.interact(local=locals())
With this, I can use the console, but in the command prompt it doesn't work. I'm also not getting the >>> signs. Any thoughts?
Reply
#8
(Apr-10-2020, 09:59 AM)PythonGainz Wrote: Using Spyder (Python 3.7) on windows ffiw.
Spyder comes with interactive shell it use IPython.
It look different so eg in [1] is the same as >>>.
Here screenshot with code in Spyder,first i push run button then use in IPython shell to do the same.
[Image: qBT8Pp.png]
Reply
#9
Thanks so much guys!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Equality in Python el_bueno 8 3,353 Feb-08-2020, 03:33 PM
Last Post: el_bueno
  Dictionnaries - Equality SupaFlamme 3 2,691 Jan-13-2019, 04:50 PM
Last Post: perfringo
  Problems with Equality of Numbers SheeppOSU 3 2,332 Jan-04-2019, 07:34 AM
Last Post: Gribouillis
  Shared reference and equality zyo 3 3,096 Jun-30-2018, 07:10 PM
Last Post: ljmetzger

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020