Print/ String variables

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Math Speak
    New Member
    • Feb 2012
    • 1

    Print/ String variables

    Hi,

    Very basic question, as I am absolute greenhorn.

    When I run this code:

    first_name='Mat h'
    last_name='Spea k'
    print (first_name, last_name)

    and the output looks like:
    ('Math','Speak' )

    where as I was expecting:
    Math Speak

    Is it to do with the version on my mac:2.7.1, where as the book am referring to recommends 3.2.2?

    Thanks
  • Smygis
    New Member
    • Jun 2007
    • 126

    #2
    In python 2.7 print (first_name, last_name) print the representation of the truple (first_name, last_name). If you remove the parentheses it will print the strings first_name and last_name.

    In python 2.x print is a statment and does not use parentheses.

    In python 3.x print is a function and requires parentheses.

    Comment

    Working...