Python Forum

Full Version: Why can't I print numbers in Python?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am using Python 3.5 with IDLE for Python 3.5.

Whenever I try to print numbers, I have to use quotation marks like I was printing script. Whenever I try to do it with just the brackets, or with a minus sign, I get a message that says "unexpected indent".

Here is the code I am typing:

print (7)

Why isn't this working?
My guess is that you're indenting something. Without seeing the actual code and error message, anything else would be random speculation.
Can not have a space if typing in IDLE(start in interactive mode >>>).
Run as script File --> New File,write or paste in code save with .py extension,Run Module(F5).
λ python
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) [MSC v.1914 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> print(7)
7
>>> print('7')
7

# One space and get your error.
>>>  print(7))
  File "<stdin>", line 1
    print(7))
    ^
IndentationError: unexpected indent
>>>
Look at Python 3.6/3.7 and pip installation under Windows
Install 3.7 if you on Windows.