471,313 Members | 1,938 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,313 software developers and data experts.

str.split() question

cwoozy
5
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?
Sep 27 '07 #1
3 1323
bvdet
2,851 Expert Mod 2GB
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:
Expand|Select|Wrap|Line Numbers
  1. >>> name = 'Donald Smith'
  2. >>> name.replace(" ", "")
  3. 'DonaldSmith'
  4. >>> 
Sep 27 '07 #2
ilikepython
844 Expert 512MB
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:
Expand|Select|Wrap|Line Numbers
  1. name = "Donald Smith"
  2. name = "".join(name.split())
  3. print name
  4.  
Sep 27 '07 #3
cwoozy
5
Thank you both for the quick reply and informative answers!
Sep 27 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by alexk | last post: by
2 posts views Thread by SL_McManus | last post: by
3 posts views Thread by rxl124 | last post: by
6 posts views Thread by Senthil | last post: by
3 posts views Thread by John Salerno | last post: by
5 posts views Thread by KC | last post: by
4 posts views Thread by Michele Petrazzo | last post: by
7 posts views Thread by Matthias Winterland | last post: by
1 post views Thread by John | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.