-1

Halli, I'm a beginner in Python. I learn with books. When describing a tuple, the brackets are also output when printing. This is not the case in the book. Do I have a mistake somewhere?

test=(12,12)
print (test) 

Python 3.5.4 (default, Feb 11 2018, 12:46:54) 
[GCC 6.4.0] on linux
Type "copyright", "credits" or "license()" for more information.
>>> 
=================== RESTART: /home/fridolin/python/test.py ===================
(12, 12)
>>> 

http://edv-bildung.de/question-in-python

vaultah
  • 44,105
  • 12
  • 114
  • 143
  • is that link a reference to the book? – Steven Black Apr 03 '18 at 16:45
  • The code you posted in your question and the code in the screenshot are literally the same. Where's that difference in output you're talking about? – Aran-Fey Apr 03 '18 at 16:45
  • can you copy the original code in the book so we can see what the "case is in the book" – clarity123 Apr 03 '18 at 16:47
  • `test` is a tuple. Because this is an important aspect of `test` the parentheses are also printed to make this clear. That is, you seem to think that just the numbers should be printed, but `test` isn't just two numbers, it's a tuple of two numbers, that is, a specific type of python object. – tom10 Apr 03 '18 at 16:52
  • the code is from the book. I would not need to take a screenshot. The book displays as output 12, 12. I get as output (12, 12) - why? – monsterherz Apr 03 '18 at 16:54
  • Many thanks. i learn :-) – monsterherz Apr 03 '18 at 16:56
  • the text is wrong probably , () defines the characteristic of a tuple like test=[12,12] gives square brackets in printing – Jiss Raphel Apr 03 '18 at 16:57
  • 1
    The book may be using python 2. – Aran-Fey Apr 03 '18 at 16:59

1 Answers1

1

No this is not a mistake. When a tuple is printed it will be displayed as ().

Take a look at this. https://stackoverflow.com/a/626871/9439504

TL-Py
  • 49
  • 1
  • 6
  • Welcome to StackOverflow! Perhaps you can add more details, to explain better the most important parts of your answer. Have a read of [How do I write a good answer?](https://stackoverflow.com/help/how-to-answer) for more information. Also, once you get more reputation, you will be able to post this as a comment rather than an answer, which would be more appropriate. – Francesco B. Apr 03 '18 at 17:08