Thread: Little help !!!

  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Rep Power

    Little help !!!

    i`m new in python i download video tutorials but they are in python 2.6 and i use 3.3 so in one tutorials when i do this little program

    x = input("Enter name: ")
    print ("Hey ") + x

    i get

    Enter name: Goce
    Traceback (most recent call last):
    File "D:\Python test\", line 2, in <module>
    print ("Hey ") + x
    TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

    Can some one help me please because of this i cant go and learn the new tutorials because i get all the time the same massage. And i have no idea where i make my mistake.

    Thanks !!!
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Rep Power
    Print was changed in Python 3 to be a built-in function rather than a keyword signalling a special statement. The way to do this in Python 3 is print("Hey", x). There are many other differences between Python 2 and 3 that you should probably familiarize yourself with if you intend to continue using a Python 2 tutorial with Python 3.
  4. #3
  5. Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Aug 2011
    Rep Power
    In python3 print returns None
    That explains the source of the None in the error message.

    (and of course in python 2 print is a statement, and statements don't have values.)
    [code]Code tags[/code] are essential for python code and Makefiles!
  6. #4
  7. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2005
    Rep Power
    Ideally (Python3) it should be ...
    x = input("Enter name: ")
    print("Hey {}".format(x))
    Real Programmers always confuse Christmas and Halloween because Oct31 == Dec25

IMN logo majestic logo threadwatch logo seochat tools logo