On 1/31/2019 1:36 PM, Grant Edwards wrote:
On 2019-01-31, Grant Edwards wrote:
On 2019-01-31, Terry Reedy wrote:
On 1/31/2019 11:19 AM, Ian Clark wrote:
text = "The best day of my life!"
output = ''
for i in text:
if i == ' ':
output +='\n'
else:
output += i
print(output)
On 2019-01-31, ^Bart wrote:
> Hello everybody! :)
>
> I got a text and I should replace every space with \n without to use
> str.replace, I thought something like this:
>
> text = "The best day of my life!"
>
> space = (' ')
>
> if text.count(' ') in text:
> space=\n
>
> rightText = text-spa
On 2019-01-31, ^Bart wrote:
> Hello everybody! :)
>
> I got a text and I should replace every space with \n without to use
> str.replace, I thought something like this:
>
> text = "The best day of my life!"
[...]
> I should have an output like this:
> The
> best
> day
> of
> my
> life!
Here's
On Fri, Feb 1, 2019 at 5:34 AM Grant Edwards wrote:
>
> On 2019-01-31, Terry Reedy wrote:
> > On 1/31/2019 11:19 AM, Ian Clark wrote:
> >> text = "The best day of my life!"
> >> output = ''
> >>
> >> for i in text:
> >> if i == ' ':
> >>output +='\n'
> >> else:
> >>output += i
> >>
>
On 2019-01-31, Grant Edwards wrote:
> On 2019-01-31, Terry Reedy wrote:
>> On 1/31/2019 11:19 AM, Ian Clark wrote:
>>> text = "The best day of my life!"
>>> output = ''
>>>
>>> for i in text:
>>> if i == ' ':
>>>output +='\n'
>>> else:
>>>output += i
>>>
>>> print(output)
>
>> But t
On 2019-01-31, Terry Reedy wrote:
> On 1/31/2019 11:19 AM, Ian Clark wrote:
>> text = "The best day of my life!"
>> output = ''
>>
>> for i in text:
>> if i == ' ':
>>output +='\n'
>> else:
>>output += i
>>
>> print(output)
> But this is an awful, O(n*n) way to solve an inherently O
On 1/31/2019 11:19 AM, Ian Clark wrote:
text = "The best day of my life!"
output = ''
for i in text:
if i == ' ':
output +='\n'
else:
output += i
print(output)
throwing my hat in the ring, not only is it .replace free it is entirely
method free
But this is an awful, O(n*n) way to s
It is amazing to watch what happens when a fairly simple question is asked
to see how people answer.
In an effort not to ramble, I will summarize my thoughts. The student wanted
to know how to solve a problem using only what they already should know and
that specifically they should not use a meth
text = "The best day of my life!"
output = ''
for i in text:
if i == ' ':
output +='\n'
else:
output += i
print(output)
throwing my hat in the ring, not only is it .replace free it is entirely
method free
On Thu, Jan 31, 2019 at 3:41 AM ^Bart wrote:
> [Solved by myself and I'm happy!!!
[Solved by myself and I'm happy!!! :)]
text = "The best day of my life!"
space = text[3]
print (text.replace(space, "\n"))
[Like what I said in another message, in the afternoon I'll ask to the
teacher if for this exercise we're able to use .replace]
--
https://mail.python.org/mailman/listin
hi ^Bert,
I've just thought that you don't like to use text.replace(' ', '\n'), and so I
came up with another way to get the job done.
So it was part of a "school-test" - uiuitststs ;-)
follow the hint from Peter then, and inside *your* for-loop ask yourself, how
to inspect the value of c in a
On Thu, Jan 31, 2019 at 9:56 PM ^Bart wrote:
>
> >You coulde use »sub« from the module »re«, then.
> >(The Python Library Reference, Release 3.8.0a0 -
> >6.2 re - Regular expression operations)
>
> We're using 3.7.2 :\
>
Don't worry about that difference - 3.8 is only minorly differen
On 31/01/19 11:47, ^Bart wrote:
>> . A correct answer to the exercise would be:
>>
>> |You cannot replace a space with \n in a string,
>> |because strings are immutable in Python.
>
> Yes, I thought in a wrong way! :)
>
Well maybe you can turn the string into a list of characters. Then
replace t
No it is not the proper way of a school test to copy what others provided.
You're right but I need just to understand what tools I should use, it
could be nice if the teacher says something like "use just these three
tools to solve this problem" or "you don't need to use these other tools
to
You coulde use »sub« from the module »re«, then.
(The Python Library Reference, Release 3.8.0a0 -
6.2 re - Regular expression operations)
We're using 3.7.2 :\
Otherwise,
Write a loop that takes the first character from
the source and appends it to a new string until
there
. A correct answer to the exercise would be:
|You cannot replace a space with \n in a string,
|because strings are immutable in Python.
Yes, I thought in a wrong way! :)
--
https://mail.python.org/mailman/listinfo/python-list
Il 31/01/19 10:34, Michael Poeltl ha scritto:
hi,
Maybe this is a proper way to do what you'd liked to achieve
text = "The best day of my life!"
newtext = '\n'.join( text.split() )
print(newtext)
The
best
day
of
my
life!
yours
Michael
Thanks Michael, I'll ask to my teacher in the afterno
Have you even tried to run this?
No, it doesn't run, it's just a personal idea! :)
I don't think this does what you think it does.
text.count(' ') will return 5, an integer. So you are testing if 5 is in text.
But since
5 is an integer that will raise a TypeError.
Yes, I understood this is
On 31/01/19 10:37, Michael Poeltl wrote:
> hi,
>
> ^Bart ended in a Mail-Delivery...
> so I send it ONLY to the python-list
>
> ^Bert, a proper way to do what you'd liked to achieve is the following:
No it is not the proper way of a school test to copy what others provided.
--
Antoon.
--
htt
On 31/01/19 10:18, ^Bart wrote:
> Hello everybody! :)
>
> I got a text and I should replace every space with \n without to use
> str.replace, I thought something like this:
Have you even tried to run this?
>
> text = "The best day of my life!"
>
> space = (' ')
>
> if text.count(' ') in text:
>
^Bart wrote:
>> Why?
>
> It's a school test, now we should use just what we studied, if than,
> else, sequences, etc.!
>
> ^Bart
Hint: you can iterate over the characters of a string
>>> for c in "hello":
... print(c)
...
h
e
l
l
o
--
https://mail.python.org/mailman/listinfo/python-l
hi,
^Bart ended in a Mail-Delivery...
so I send it ONLY to the python-list
^Bert, a proper way to do what you'd liked to achieve is the following:
>>> text = "The best day of my life!"
>>> newtext = '\n'.join( text.split() )
>>> print(newtext)
The
best
day
of
my
life!
>>>
regards
Michael
* ^B
hi,
Maybe this is a proper way to do what you'd liked to achieve
>>> text = "The best day of my life!"
>>> newtext = '\n'.join( text.split() )
>>> print(newtext)
The
best
day
of
my
life!
>>>
yours
Michael
* ^Bart [2019-01-31 10:22]:
> Hello everybody! :)
>
> I got a text and I should replace e
maybe this is an alternative way to get your wished result.
>>> text = "The best day of my life!"
>>> newtext = '\n'.join( text.split() )
>>> print(newtext)
The
best
day
of
my
life!
>>>
yours
Michael
* ^Bart [2019-01-31 10:22]:
> Hello everybody! :)
>
> I got a text and I should replace every s
Why?
It's a school test, now we should use just what we studied, if than,
else, sequences, etc.!
^Bart
--
https://mail.python.org/mailman/listinfo/python-list
On Thu, 31 Jan 2019 10:18:20 +0100, ^Bart wrote:
> Hello everybody! :)
>
> I got a text and I should replace every space with \n without to use
> str.replace,
Why?
> I thought something like this:
>
> text = "The best day of my life!"
>
> space = (' ')
>
> if text.count(' ') in text:
>
Hello everybody! :)
I got a text and I should replace every space with \n without to use
str.replace, I thought something like this:
text = "The best day of my life!"
space = (' ')
if text.count(' ') in text:
space=\n
rightText = text-space
print(rightText)
I should have an output
27 matches
Mail list logo