In python, can't delete the period '.' The Next CEO of Stack OverflowCalling 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
Would this house-rule that treats advantage as a +1 to the roll instead (and disadvantage as -1) and allows them to stack be balanced?
INSERT to a table from a database to other (same SQL Server) using Dynamic SQL
Is micro rebar a better way to reinforce concrete than rebar?
Is French Guiana a (hard) EU border?
Find non-case sensitive string in a mixed list of elements?
Chain wire methods together in Lightning Web Components
What happened in Rome, when the western empire "fell"?
Domestic-to-international connection at Orlando (MCO)
How many extra stops do monopods offer for tele photographs?
Dominated convergence theorem - what sequence?
Why is my new battery behaving weirdly?
Can we say or write : "No, it'sn't"?
What flight has the highest ratio of time difference to flight time?
I believe this to be a fraud - hired, then asked to cash check and send cash as Bitcoin
What connection does MS Office have to Netscape Navigator?
Are police here, aren't itthey?
Why don't programming languages automatically manage the synchronous/asynchronous problem?
When you upcast Blindness/Deafness, do all targets suffer the same effect?
Can a Bladesinger Wizard use Bladesong with a Hand Crossbow?
Axiom Schema vs Axiom
Reference request: Grassmannian and Plucker coordinates in type B, C, D
Does soap repel water?
Do I need to write [sic] when a number is less than 10 but isn't written out?
Why does standard notation not preserve intervals (visually)
In python, can't delete the period '.'
The Next CEO of Stack OverflowCalling 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
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,40711024
5,40711024
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.5k74054
13.5k74054
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