Python Forum
Checking for equality - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Checking for equality (/thread-25720.html)



Checking for equality - PythonGainz - Apr-09-2020

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.


RE: Checking for equality - buran - Apr-09-2020

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



RE: Checking for equality - PythonGainz - Apr-10-2020

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.


RE: Checking for equality - buran - Apr-10-2020

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.


RE: Checking for equality - ndc85430 - Apr-10-2020

Did you look at the docs for Spyder? It seems to have an IPython console.


RE: Checking for equality - PythonGainz - Apr-10-2020

I've typed "python" and "python3" into the command promt and the console. Doesn't do anything unfortunately.


RE: Checking for equality - PythonGainz - Apr-10-2020

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?


RE: Checking for equality - snippsat - Apr-10-2020

(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]


RE: Checking for equality - PythonGainz - Apr-10-2020

Thanks so much guys!