0

Python newbie here. While running .py files or using the python command line in PyCharm, I see that built-in functions don't seem to work:

Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32 bit (Intel)] on win32
>>> range(5, 30, 5)
range(5, 30, 5)

Similarly, when I try to use raw_input():

>>> x = raw_input('please enter a number')
Traceback (most recent call last):
  File "<input>", line 1, in <module>
NameError: name 'raw_input' is not defined

I can use map but can't seem to see the result - just the 'map object':

>>> def cube(x): return x*x*x
>>> map(cube, range(1, 11))
<map object at 0x03021F50>
>>> g = map(cube, range(1,11))
>>> g
<map object at 0x03027190>
>>> g[1]
Traceback (most recent call last):
  File "<input>", line 1, in <module>
TypeError: 'map' object is not subscriptable

If I run Python from my windows command line, these commands run fine. Any tips to figure out what's going wrong here?

Mikko Ohtamaa
  • 82,057
  • 50
  • 264
  • 435
sunny
  • 3,853
  • 5
  • 32
  • 62

1 Answers1

1

Python 3 does not have raw_input only input.

How do I use raw_input in Python 3

Maybe you are confusing different Python interpreter versions here.

Community
  • 1
  • 1
Mikko Ohtamaa
  • 82,057
  • 50
  • 264
  • 435
  • thanks for this tip, but in that case why does the command work on my console? Also why do the other functions not work (all in different ways)? – sunny May 05 '15 at 17:03
  • 1
    Check your Python version using the command: `import sys ; sys.version` - there are breaking changes between Python version 2 and Python version 3 - that's why some things behave differently, justifying the major version number change. – Mikko Ohtamaa May 05 '15 at 17:14