In python, can't delete the period '.' Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experience Should we burninate the [wrap] tag?Calling an external command in PythonWhat are metaclasses in Python?Finding the index of an item given a list containing it in PythonDifference between append vs. extend list methods in PythonHow can I safely create a nested directory in Python?Does Python have a ternary conditional operator?How to get the current time in PythonHow can I make a time delay in Python?Does Python have a string 'contains' substring method?Delete a file or folder
How does a Death Domain cleric's Touch of Death feature work with Touch-range spells delivered by familiars?
Can a non-EU citizen traveling with me come with me through the EU passport line?
Right-skewed distribution with mean equals to mode?
When -s is used with third person singular. What's its use in this context?
Are my PIs rude or am I just being too sensitive?
What is a Meta algorithm?
Why one of virtual NICs called bond0?
Do I really need recursive chmod to restrict access to a folder?
3 doors, three guards, one stone
If Jon Snow became King of the Seven Kingdoms what would his regnal number be?
Single word antonym of "flightless"
Using et al. for a last / senior author rather than for a first author
Is there a concise way to say "all of the X, one of each"?
Doubts about chords
Is there a Spanish version of "dot your i's and cross your t's" that includes the letter 'ñ'?
Is there a documented rationale why the House Ways and Means chairman can demand tax info?
Proof involving the spectral radius and Jordan Canonical form
Why is "Consequences inflicted." not a sentence?
I am not a queen, who am I?
How do I stop a creek from eroding my steep embankment?
Does accepting a pardon have any bearing on trying that person for the same crime in a sovereign jurisdiction?
Why is black pepper both grey and black?
How to bypass password on Windows XP account?
What are 'alternative tunings' of a guitar and why would you use them? Doesn't it make it more difficult to play?
In python, can't delete the period '.'
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
The Ask Question Wizard is Live!
Data science time! April 2019 and salary with experience
Should we burninate the [wrap] tag?Calling an external command in PythonWhat are metaclasses in Python?Finding the index of an item given a list containing it in PythonDifference between append vs. extend list methods in PythonHow can I safely create a nested directory in Python?Does Python have a ternary conditional operator?How to get the current time in PythonHow can I make a time delay in Python?Does Python have a string 'contains' substring method?Delete a file or folder
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
Trying to figure out how to delete the period from my output. The correct answer to the assignment is: WA. EA. AI. AR. VI
My output is: WA. EA. AI. AR. VI.
I've tried using rstrip to remove the . from the output but that does not work.
Appreciate some insight to this rookie python programmer.
stopwords = ['to', 'a', 'for', 'by', 'an', 'am', 'the',
'so', 'it', 'and', 'The']
sent = "The water earth and air are vital"
s_sent=sent.split()
acro = ''
for word in s_sent:
if word not in stopwords:
acro=acro + str.upper(word[:2])+". "
acro=acro.rstrip('.')
print(acro)
python
add a comment |
Trying to figure out how to delete the period from my output. The correct answer to the assignment is: WA. EA. AI. AR. VI
My output is: WA. EA. AI. AR. VI.
I've tried using rstrip to remove the . from the output but that does not work.
Appreciate some insight to this rookie python programmer.
stopwords = ['to', 'a', 'for', 'by', 'an', 'am', 'the',
'so', 'it', 'and', 'The']
sent = "The water earth and air are vital"
s_sent=sent.split()
acro = ''
for word in s_sent:
if word not in stopwords:
acro=acro + str.upper(word[:2])+". "
acro=acro.rstrip('.')
print(acro)
python
3
.rstrip('.')
won't work as the last character is already' '
. Also that's inside the loop, so you're trying to remove a character you just explicitly added. Maybe justacro[:-2]
outside the loop?
– jonrsharpe
Mar 8 at 15:49
add a comment |
Trying to figure out how to delete the period from my output. The correct answer to the assignment is: WA. EA. AI. AR. VI
My output is: WA. EA. AI. AR. VI.
I've tried using rstrip to remove the . from the output but that does not work.
Appreciate some insight to this rookie python programmer.
stopwords = ['to', 'a', 'for', 'by', 'an', 'am', 'the',
'so', 'it', 'and', 'The']
sent = "The water earth and air are vital"
s_sent=sent.split()
acro = ''
for word in s_sent:
if word not in stopwords:
acro=acro + str.upper(word[:2])+". "
acro=acro.rstrip('.')
print(acro)
python
Trying to figure out how to delete the period from my output. The correct answer to the assignment is: WA. EA. AI. AR. VI
My output is: WA. EA. AI. AR. VI.
I've tried using rstrip to remove the . from the output but that does not work.
Appreciate some insight to this rookie python programmer.
stopwords = ['to', 'a', 'for', 'by', 'an', 'am', 'the',
'so', 'it', 'and', 'The']
sent = "The water earth and air are vital"
s_sent=sent.split()
acro = ''
for word in s_sent:
if word not in stopwords:
acro=acro + str.upper(word[:2])+". "
acro=acro.rstrip('.')
print(acro)
python
python
asked Mar 8 at 15:48
Rick CrespoRick Crespo
41
41
3
.rstrip('.')
won't work as the last character is already' '
. Also that's inside the loop, so you're trying to remove a character you just explicitly added. Maybe justacro[:-2]
outside the loop?
– jonrsharpe
Mar 8 at 15:49
add a comment |
3
.rstrip('.')
won't work as the last character is already' '
. Also that's inside the loop, so you're trying to remove a character you just explicitly added. Maybe justacro[:-2]
outside the loop?
– jonrsharpe
Mar 8 at 15:49
3
3
.rstrip('.')
won't work as the last character is already ' '
. Also that's inside the loop, so you're trying to remove a character you just explicitly added. Maybe just acro[:-2]
outside the loop?– jonrsharpe
Mar 8 at 15:49
.rstrip('.')
won't work as the last character is already ' '
. Also that's inside the loop, so you're trying to remove a character you just explicitly added. Maybe just acro[:-2]
outside the loop?– jonrsharpe
Mar 8 at 15:49
add a comment |
3 Answers
3
active
oldest
votes
You join
to save yourself from troubles of handling the left over spaces and
'.'
stopwords = ['to', 'a', 'for', 'by', 'an', 'am', 'the',
'so', 'it', 'and', 'The']
sent = "The water earth and air are vital"
s_sent=sent.split()
acro = []
for word in s_sent:
if word not in stopwords:
acro.append( str.upper(word[:2]))
print('. '.join(acro))
Output
WA. EA. AI. AR. VI
Another simple way is to introduce a flag to check the first value and then smartly append '. '
at the end of last value. In this way you will not have extra trailing characters
smart_flag = True
acro = ''
for word in s_sent:
if word not in stopwords:
if smart_flag:
acro=acro+str.upper(word[:2])
smart_flag=False
else:
acro=acro +". " + str.upper(word[:2])
print(acro)
Just for completeness acro.rstrip(' .'))
will strip any characters you pass in.By that I mean it will remove '. '
as well as ' .'
word[:2].upper()
:)
– han solo
Mar 8 at 15:56
''.join(map(str.upper, text[:2]))
:)
– Matias Cicero
Mar 8 at 16:14
Thanks for everyone's comments. I'm taking a MOOC in python and enjoy learning how to program. The challenge is learning which type of problem lends itself to one type of solution vice another. In my example, it seems as if using join after appending to a list is better suited than concatenating strings, which is what I was doing. I definitely need more experience in the finer details such as mutating lists and formatting. Thanks for the assist.
– Rick Crespo
Mar 8 at 19:03
add a comment |
This is because your last character in acro
is a space character. You have to either rstrip(". ")
or rstrip(" .")
.
add a comment |
This can also be shortened to this:
stopwords = ['to', 'a', 'for', 'by', 'an', 'am', 'the', 'so', 'it', 'and', 'The']
sent = "The water earth and air are vital"
acro = '. '.join(word[:2].upper() for word in sent.split() if word not in stopwords)
print(acro)
Output:
WA. EA. AI. AR. VI
Update:
But, as @mad_ points out, join
in this case would like to create a single string, first of exactly the right length, then with the right contents. But to know the right length it would like to find the lengths of all the components it is going to join, so having a list as its parameter would mean it has a size, whereas my original answer with a generator does not have a size until it has been exhausted.
So, better is:
acro = '. '.join([word[:2].upper() for word in sent.split() if word not in stopwords])
List comprehension will be faster in these cases while usingjoin
– mad_
Mar 8 at 17:19
@quamrana your suggestions worked well. can you explain in your line "why" it does not add a period at the end? I'm assuming because there are not any spaces after the I? It's a bit fuzzy to me. thanks in advance
– Rick Crespo
Mar 8 at 19:28
@mad_ can offer an explanation at the 100 level why your code does not put a period at the end? thanks
– Rick Crespo
Mar 8 at 19:29
The join function does this for you.
– quamrana
Mar 8 at 22:31
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55066629%2fin-python-cant-delete-the-period%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
You join
to save yourself from troubles of handling the left over spaces and
'.'
stopwords = ['to', 'a', 'for', 'by', 'an', 'am', 'the',
'so', 'it', 'and', 'The']
sent = "The water earth and air are vital"
s_sent=sent.split()
acro = []
for word in s_sent:
if word not in stopwords:
acro.append( str.upper(word[:2]))
print('. '.join(acro))
Output
WA. EA. AI. AR. VI
Another simple way is to introduce a flag to check the first value and then smartly append '. '
at the end of last value. In this way you will not have extra trailing characters
smart_flag = True
acro = ''
for word in s_sent:
if word not in stopwords:
if smart_flag:
acro=acro+str.upper(word[:2])
smart_flag=False
else:
acro=acro +". " + str.upper(word[:2])
print(acro)
Just for completeness acro.rstrip(' .'))
will strip any characters you pass in.By that I mean it will remove '. '
as well as ' .'
word[:2].upper()
:)
– han solo
Mar 8 at 15:56
''.join(map(str.upper, text[:2]))
:)
– Matias Cicero
Mar 8 at 16:14
Thanks for everyone's comments. I'm taking a MOOC in python and enjoy learning how to program. The challenge is learning which type of problem lends itself to one type of solution vice another. In my example, it seems as if using join after appending to a list is better suited than concatenating strings, which is what I was doing. I definitely need more experience in the finer details such as mutating lists and formatting. Thanks for the assist.
– Rick Crespo
Mar 8 at 19:03
add a comment |
You join
to save yourself from troubles of handling the left over spaces and
'.'
stopwords = ['to', 'a', 'for', 'by', 'an', 'am', 'the',
'so', 'it', 'and', 'The']
sent = "The water earth and air are vital"
s_sent=sent.split()
acro = []
for word in s_sent:
if word not in stopwords:
acro.append( str.upper(word[:2]))
print('. '.join(acro))
Output
WA. EA. AI. AR. VI
Another simple way is to introduce a flag to check the first value and then smartly append '. '
at the end of last value. In this way you will not have extra trailing characters
smart_flag = True
acro = ''
for word in s_sent:
if word not in stopwords:
if smart_flag:
acro=acro+str.upper(word[:2])
smart_flag=False
else:
acro=acro +". " + str.upper(word[:2])
print(acro)
Just for completeness acro.rstrip(' .'))
will strip any characters you pass in.By that I mean it will remove '. '
as well as ' .'
word[:2].upper()
:)
– han solo
Mar 8 at 15:56
''.join(map(str.upper, text[:2]))
:)
– Matias Cicero
Mar 8 at 16:14
Thanks for everyone's comments. I'm taking a MOOC in python and enjoy learning how to program. The challenge is learning which type of problem lends itself to one type of solution vice another. In my example, it seems as if using join after appending to a list is better suited than concatenating strings, which is what I was doing. I definitely need more experience in the finer details such as mutating lists and formatting. Thanks for the assist.
– Rick Crespo
Mar 8 at 19:03
add a comment |
You join
to save yourself from troubles of handling the left over spaces and
'.'
stopwords = ['to', 'a', 'for', 'by', 'an', 'am', 'the',
'so', 'it', 'and', 'The']
sent = "The water earth and air are vital"
s_sent=sent.split()
acro = []
for word in s_sent:
if word not in stopwords:
acro.append( str.upper(word[:2]))
print('. '.join(acro))
Output
WA. EA. AI. AR. VI
Another simple way is to introduce a flag to check the first value and then smartly append '. '
at the end of last value. In this way you will not have extra trailing characters
smart_flag = True
acro = ''
for word in s_sent:
if word not in stopwords:
if smart_flag:
acro=acro+str.upper(word[:2])
smart_flag=False
else:
acro=acro +". " + str.upper(word[:2])
print(acro)
Just for completeness acro.rstrip(' .'))
will strip any characters you pass in.By that I mean it will remove '. '
as well as ' .'
You join
to save yourself from troubles of handling the left over spaces and
'.'
stopwords = ['to', 'a', 'for', 'by', 'an', 'am', 'the',
'so', 'it', 'and', 'The']
sent = "The water earth and air are vital"
s_sent=sent.split()
acro = []
for word in s_sent:
if word not in stopwords:
acro.append( str.upper(word[:2]))
print('. '.join(acro))
Output
WA. EA. AI. AR. VI
Another simple way is to introduce a flag to check the first value and then smartly append '. '
at the end of last value. In this way you will not have extra trailing characters
smart_flag = True
acro = ''
for word in s_sent:
if word not in stopwords:
if smart_flag:
acro=acro+str.upper(word[:2])
smart_flag=False
else:
acro=acro +". " + str.upper(word[:2])
print(acro)
Just for completeness acro.rstrip(' .'))
will strip any characters you pass in.By that I mean it will remove '. '
as well as ' .'
edited Mar 8 at 16:04
answered Mar 8 at 15:53
mad_mad_
5,41711024
5,41711024
word[:2].upper()
:)
– han solo
Mar 8 at 15:56
''.join(map(str.upper, text[:2]))
:)
– Matias Cicero
Mar 8 at 16:14
Thanks for everyone's comments. I'm taking a MOOC in python and enjoy learning how to program. The challenge is learning which type of problem lends itself to one type of solution vice another. In my example, it seems as if using join after appending to a list is better suited than concatenating strings, which is what I was doing. I definitely need more experience in the finer details such as mutating lists and formatting. Thanks for the assist.
– Rick Crespo
Mar 8 at 19:03
add a comment |
word[:2].upper()
:)
– han solo
Mar 8 at 15:56
''.join(map(str.upper, text[:2]))
:)
– Matias Cicero
Mar 8 at 16:14
Thanks for everyone's comments. I'm taking a MOOC in python and enjoy learning how to program. The challenge is learning which type of problem lends itself to one type of solution vice another. In my example, it seems as if using join after appending to a list is better suited than concatenating strings, which is what I was doing. I definitely need more experience in the finer details such as mutating lists and formatting. Thanks for the assist.
– Rick Crespo
Mar 8 at 19:03
word[:2].upper()
:)– han solo
Mar 8 at 15:56
word[:2].upper()
:)– han solo
Mar 8 at 15:56
''.join(map(str.upper, text[:2]))
:)– Matias Cicero
Mar 8 at 16:14
''.join(map(str.upper, text[:2]))
:)– Matias Cicero
Mar 8 at 16:14
Thanks for everyone's comments. I'm taking a MOOC in python and enjoy learning how to program. The challenge is learning which type of problem lends itself to one type of solution vice another. In my example, it seems as if using join after appending to a list is better suited than concatenating strings, which is what I was doing. I definitely need more experience in the finer details such as mutating lists and formatting. Thanks for the assist.
– Rick Crespo
Mar 8 at 19:03
Thanks for everyone's comments. I'm taking a MOOC in python and enjoy learning how to program. The challenge is learning which type of problem lends itself to one type of solution vice another. In my example, it seems as if using join after appending to a list is better suited than concatenating strings, which is what I was doing. I definitely need more experience in the finer details such as mutating lists and formatting. Thanks for the assist.
– Rick Crespo
Mar 8 at 19:03
add a comment |
This is because your last character in acro
is a space character. You have to either rstrip(". ")
or rstrip(" .")
.
add a comment |
This is because your last character in acro
is a space character. You have to either rstrip(". ")
or rstrip(" .")
.
add a comment |
This is because your last character in acro
is a space character. You have to either rstrip(". ")
or rstrip(" .")
.
This is because your last character in acro
is a space character. You have to either rstrip(". ")
or rstrip(" .")
.
answered Mar 8 at 15:51
pi.pi.
13.8k53051
13.8k53051
add a comment |
add a comment |
This can also be shortened to this:
stopwords = ['to', 'a', 'for', 'by', 'an', 'am', 'the', 'so', 'it', 'and', 'The']
sent = "The water earth and air are vital"
acro = '. '.join(word[:2].upper() for word in sent.split() if word not in stopwords)
print(acro)
Output:
WA. EA. AI. AR. VI
Update:
But, as @mad_ points out, join
in this case would like to create a single string, first of exactly the right length, then with the right contents. But to know the right length it would like to find the lengths of all the components it is going to join, so having a list as its parameter would mean it has a size, whereas my original answer with a generator does not have a size until it has been exhausted.
So, better is:
acro = '. '.join([word[:2].upper() for word in sent.split() if word not in stopwords])
List comprehension will be faster in these cases while usingjoin
– mad_
Mar 8 at 17:19
@quamrana your suggestions worked well. can you explain in your line "why" it does not add a period at the end? I'm assuming because there are not any spaces after the I? It's a bit fuzzy to me. thanks in advance
– Rick Crespo
Mar 8 at 19:28
@mad_ can offer an explanation at the 100 level why your code does not put a period at the end? thanks
– Rick Crespo
Mar 8 at 19:29
The join function does this for you.
– quamrana
Mar 8 at 22:31
add a comment |
This can also be shortened to this:
stopwords = ['to', 'a', 'for', 'by', 'an', 'am', 'the', 'so', 'it', 'and', 'The']
sent = "The water earth and air are vital"
acro = '. '.join(word[:2].upper() for word in sent.split() if word not in stopwords)
print(acro)
Output:
WA. EA. AI. AR. VI
Update:
But, as @mad_ points out, join
in this case would like to create a single string, first of exactly the right length, then with the right contents. But to know the right length it would like to find the lengths of all the components it is going to join, so having a list as its parameter would mean it has a size, whereas my original answer with a generator does not have a size until it has been exhausted.
So, better is:
acro = '. '.join([word[:2].upper() for word in sent.split() if word not in stopwords])
List comprehension will be faster in these cases while usingjoin
– mad_
Mar 8 at 17:19
@quamrana your suggestions worked well. can you explain in your line "why" it does not add a period at the end? I'm assuming because there are not any spaces after the I? It's a bit fuzzy to me. thanks in advance
– Rick Crespo
Mar 8 at 19:28
@mad_ can offer an explanation at the 100 level why your code does not put a period at the end? thanks
– Rick Crespo
Mar 8 at 19:29
The join function does this for you.
– quamrana
Mar 8 at 22:31
add a comment |
This can also be shortened to this:
stopwords = ['to', 'a', 'for', 'by', 'an', 'am', 'the', 'so', 'it', 'and', 'The']
sent = "The water earth and air are vital"
acro = '. '.join(word[:2].upper() for word in sent.split() if word not in stopwords)
print(acro)
Output:
WA. EA. AI. AR. VI
Update:
But, as @mad_ points out, join
in this case would like to create a single string, first of exactly the right length, then with the right contents. But to know the right length it would like to find the lengths of all the components it is going to join, so having a list as its parameter would mean it has a size, whereas my original answer with a generator does not have a size until it has been exhausted.
So, better is:
acro = '. '.join([word[:2].upper() for word in sent.split() if word not in stopwords])
This can also be shortened to this:
stopwords = ['to', 'a', 'for', 'by', 'an', 'am', 'the', 'so', 'it', 'and', 'The']
sent = "The water earth and air are vital"
acro = '. '.join(word[:2].upper() for word in sent.split() if word not in stopwords)
print(acro)
Output:
WA. EA. AI. AR. VI
Update:
But, as @mad_ points out, join
in this case would like to create a single string, first of exactly the right length, then with the right contents. But to know the right length it would like to find the lengths of all the components it is going to join, so having a list as its parameter would mean it has a size, whereas my original answer with a generator does not have a size until it has been exhausted.
So, better is:
acro = '. '.join([word[:2].upper() for word in sent.split() if word not in stopwords])
edited Mar 9 at 10:14
answered Mar 8 at 16:14
quamranaquamrana
13.8k74054
13.8k74054
List comprehension will be faster in these cases while usingjoin
– mad_
Mar 8 at 17:19
@quamrana your suggestions worked well. can you explain in your line "why" it does not add a period at the end? I'm assuming because there are not any spaces after the I? It's a bit fuzzy to me. thanks in advance
– Rick Crespo
Mar 8 at 19:28
@mad_ can offer an explanation at the 100 level why your code does not put a period at the end? thanks
– Rick Crespo
Mar 8 at 19:29
The join function does this for you.
– quamrana
Mar 8 at 22:31
add a comment |
List comprehension will be faster in these cases while usingjoin
– mad_
Mar 8 at 17:19
@quamrana your suggestions worked well. can you explain in your line "why" it does not add a period at the end? I'm assuming because there are not any spaces after the I? It's a bit fuzzy to me. thanks in advance
– Rick Crespo
Mar 8 at 19:28
@mad_ can offer an explanation at the 100 level why your code does not put a period at the end? thanks
– Rick Crespo
Mar 8 at 19:29
The join function does this for you.
– quamrana
Mar 8 at 22:31
List comprehension will be faster in these cases while using
join
– mad_
Mar 8 at 17:19
List comprehension will be faster in these cases while using
join
– mad_
Mar 8 at 17:19
@quamrana your suggestions worked well. can you explain in your line "why" it does not add a period at the end? I'm assuming because there are not any spaces after the I? It's a bit fuzzy to me. thanks in advance
– Rick Crespo
Mar 8 at 19:28
@quamrana your suggestions worked well. can you explain in your line "why" it does not add a period at the end? I'm assuming because there are not any spaces after the I? It's a bit fuzzy to me. thanks in advance
– Rick Crespo
Mar 8 at 19:28
@mad_ can offer an explanation at the 100 level why your code does not put a period at the end? thanks
– Rick Crespo
Mar 8 at 19:29
@mad_ can offer an explanation at the 100 level why your code does not put a period at the end? thanks
– Rick Crespo
Mar 8 at 19:29
The join function does this for you.
– quamrana
Mar 8 at 22:31
The join function does this for you.
– quamrana
Mar 8 at 22:31
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55066629%2fin-python-cant-delete-the-period%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
3
.rstrip('.')
won't work as the last character is already' '
. Also that's inside the loop, so you're trying to remove a character you just explicitly added. Maybe justacro[:-2]
outside the loop?– jonrsharpe
Mar 8 at 15:49