Python list


animals = [“ant”, “bat”, “cat”]
print animals.index(“bat”)

why this code given in the modules works right python IDLE or pycharm but it works correctly in codecademy ide


Hello @designrockstar36837, what you mean it works right with Python IDLE or PyCharm?

You have to take into account PyCharm requires a Python interpreter to work, so probably you have installed Python 3 version on your PC, while Codecademy uses Python 2. Hence, you print statement requires a parentheses to work:

# Python3 Code
animals = ["ant", "bat", "cat"]


Ya I mean it showed syntax error in of charm and python idle


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.