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?
3 1389 bvdet 2,851
Recognized Expert Moderator Specialist
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: - >>> name = 'Donald Smith'
-
>>> name.replace(" ", "")
-
'DonaldSmith'
-
>>>
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: -
name = "Donald Smith"
-
name = "".join(name.split())
-
print name
-
Thank you both for the quick reply and informative answers!
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: alexk |
last post by:
I've a simple question. Why the following:
words = "123#@$#$@^% wordB#@$".split('~`!@#$%^&*()_+-={},./')
doesn't work? The length of the result vector is 1.
I'm using ActivePython 2.4
Alex
|
by: SL_McManus |
last post by:
Hi All;
I am fairly new to Perl. I have a file with close to 3000 lines
that I would like to split out in a certain way. I would like to put
the record type starting in column 1 for 2 spaces, the employer code
in column 23 for 29 spaces and employer description in column 53 for
30 spaces. I have tried modifying an existing file with no real
success. I haven't found anything that specifically answers my
question. Any guidance would be...
|
by: rxl124 |
last post by:
Hi, room
Beginner of learning perl here!!
I have question to all,
I have below file name datebook.master which contains only 2 lines
Mike wolf:12/3/44:144 park ave, paramus: 44000
Sarah kim: 3/2/67:255 lomel ave, fort lee: 33000
Now, I am testing out below scripts and working fine.
|
by: Senthil |
last post by:
Code
----------------------
string Line = "\"A\",\"B\",\"C\",\"D\"";
string Line2 = Line.Replace("\",\"","\"\",\"\"");
string CSVColumns = Line2.Split("\",\"".ToCharArray());
|
by: John Salerno |
last post by:
This is an example in the book I'm reading:
string fullName = " Edward C Koop ";
fullName = fullName.Trim();
string names = fullName.Split(' ');
string firstName = names; // Edward
Two questions about this:
1. Why do you use single quotes with Split() instead of double? Is this
| |
by: KC |
last post by:
Can I do a split() on a string where the delimiter is one or more space
characters? I have a string with spaces between the numbers but I don't know
how many. You can do this easy in Perl, but VB.net ain't Perl...
Ken
|
by: Michele Petrazzo |
last post by:
Hello ng,
I don't understand why split (string split) doesn't work with the same
method if I can't pass values or if I pass a whitespace value:
>>> "".split()
>>> "".split(" ")
But into the doc I see:
|
by: Matthias Winterland |
last post by:
Hi,
I have a simple question. When I read in a string like:
a='1,2,3,4,5 6 7,3,4', can I get the list l= with a
single split-call?
Thx,
Matthias
|
by: dtex23 |
last post by:
Good afternoon all,
Question about list assignment in perl...
Given a piece of code that looks kinda like this for parsing some '|' delimited input text lines :
($var1, $var2, $var3) = split(/\|/, $listline);
Here's the hard part: There are differing programs that read from the same conf file that take data stream and split it, but at some point in the future I may need to expand the variables split to. I would like to basically put...
|
by: John |
last post by:
Hi
I have written a Split function which in turn calls the standard string
split function. Code is below;
Function Split1(ByVal Expression As String, Optional ByVal Delimiter As
String = " ", Optional ByVal Limit As Integer = -1, Optional ByVal Compare
As CompareMethod = CompareMethod.Binary, Optional ByVal MaxLength As Integer
= 0) As String()
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |