Thread: Newbie Help

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

    Join Date
    Jun 2013
    Posts
    2
    Rep Power
    0

    Newbie Help


    I am new to python and working on an assignment. I wrote a python program to ask a person there name and it prints out what they put in. My question is, how do I get the program to shorten there name to only 3 letters when I have it print out?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Location
    /dev/null
    Posts
    163
    Rep Power
    19
    Originally Posted by Turo
    My question is, how do I get the program to shorten there name to only 3 letters when I have it print out?
    Use string slicing.
    Code:
    >>> x = 'hello'
    >>> print (x[0:3])
    hel
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    2
    Rep Power
    0
    Thank you very much. I was able to get it to work.

IMN logo majestic logo threadwatch logo seochat tools logo