Python Forum
Why can't I print numbers in Python?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why can't I print numbers in Python?
#1
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?
Reply
#2
My guess is that you're indenting something. Without seeing the actual code and error message, anything else would be random speculation.
Reply
#3
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Print max numbers in a list jimmoriarty 1 2,156 Sep-25-2020, 07:29 AM
Last Post: DPaul
  Is there a way i print odd and even numbers separately? spalisetty06 5 2,719 Jul-21-2020, 06:48 PM
Last Post: spalisetty06
  Supposed to print out even numbers DallasPCMan 4 1,966 May-21-2020, 05:50 PM
Last Post: ndc85430
  first k non prime numbers print bsrohith 7 7,525 Jun-20-2019, 10:48 AM
Last Post: arycloud
  Print Numbers starting at 1 vertically with separator for output numbers Pleiades 3 3,735 May-09-2019, 12:19 PM
Last Post: Pleiades
  Print list from splitted range of numbers prashant8530 1 2,799 Sep-04-2017, 08:03 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020