A. Gupta
A. Gupta

Reputation: 1

Checking Membership in Python

In Python 3 it is working

a=["Abhi", "Gupta"]
eval(input("Please enter a string: ")) in a
Please enter a string:  "Abhi"
=> True

But in Python 2 I am getting following error

a=["Abhi", "Gupta"]
raw_input("Please enter a string: ") in a
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'bool' object is not callable

Can anyone please explain why it is not working in Python 2 and what is this "'bool' object is not callable" error as well?

Upvotes: 0

Views: 116

Answers (1)

Taku
Taku

Reputation: 33744

For the python 3 example, eval isn't necessary since input() returns str.

As for the TypeError in python 2, you must've overrode raw_input to something type bool before that line. Ie. raw_input = True or something.

Upvotes: 1

Related Questions