str.split() question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cwoozy
    New Member
    • Sep 2007
    • 5

    #1

    str.split() question

    I'm writing a program that has the user input their name, then converts their name to a "numeric value" (basically, take the ASCII value of all of the characters and add them together).

    I think I know just about everything I need to write my program, except for one thing:
    Since spaces count as 32, I would like to eliminate them from the inputted string. My first guess was to just string.split and then concatenate the two split strings, but I don't know what the two split strings would be called.
    Any tips?
  • bvdet
    Recognized Expert Specialist
    • Oct 2006
    • 2851

    #2
    Originally posted by cwoozy
    I'm writing a program that has the user input their name, then converts their name to a "numeric value" (basically, take the ASCII value of all of the characters and add them together).

    I think I know just about everything I need to write my program, except for one thing:
    Since spaces count as 32, I would like to eliminate them from the inputted string. My first guess was to just string.split and then concatenate the two split strings, but I don't know what the two split strings would be called.
    Any tips?
    Maybe this will help:[code=Python]>>> name = 'Donald Smith'
    >>> name.replace(" ", "")
    'DonaldSmith'
    >>> [/code]

    Comment

    • ilikepython
      Recognized Expert Contributor
      • Feb 2007
      • 844

      #3
      Originally posted by cwoozy
      I'm writing a program that has the user input their name, then converts their name to a "numeric value" (basically, take the ASCII value of all of the characters and add them together).

      I think I know just about everything I need to write my program, except for one thing:
      Since spaces count as 32, I would like to eliminate them from the inputted string. My first guess was to just string.split and then concatenate the two split strings, but I don't know what the two split strings would be called.
      Any tips?
      To use the str.split() function:
      [code=python]
      name = "Donald Smith"
      name = "".join(name.sp lit())
      print name
      [/code]

      Comment

      • cwoozy
        New Member
        • Sep 2007
        • 5

        #4
        Thank you both for the quick reply and informative answers!

        Comment

        Working...