Emile van Sebille wrote:
On 9/23/2009 7:22 AM Ali Sina said...
#Message backward printer
message=input('Enter your message: ')
for i in range(len(message),0,-1):
print(message)
This is the code which I have written. All it does is count the number
of letters starting from backwards. The
On Thu, Sep 24, 2009 at 7:02 PM, Sander Sweers wrote:
> Now that I know what to look for I went to the online python docs [1]
> and tried to find where it has been documented.
>
> Unfortunately all the slicing examples I found do not even mention that
> there is optional step value.
See footnote
On Thu, 2009-09-24 at 08:07 -0400, Serdar Tumgoren wrote:
> You should find plenty by googling for "python slice step sequence"
Now that I know what to look for I went to the online python docs [1]
and tried to find where it has been documented.
Unfortunately all the slicing examples I found do
> Does anyone have an advanced topic on slicing where the :: notation is
> explained?
>
You should find plenty by googling for "python slice step sequence"
Here are a few with links to further resources:
http://www.python.org/doc/2.3/whatsnew/section-slices.html
http://stackoverflow.com/questions
2009/9/24 ALAN GAULD :
>> print message[::-1]
>
> Yes, the for loop doing one character at a time will be much
> slower than using a slice. The slice is more pythonic but less general.
> A reverse loop is something that is often needed in programming
> solutions so it's useful to know how to do it
Thank you for the clear explanation.
Robert
On Wed, 2009-09-23 at 23:40 +, ALAN GAULD wrote:
> > Is there a significant difference in speed, style, or any pythonesque
> > reasoning between Alan's solution and
> > print message[::-1]
>
>
> Yes, the for loop doing one character at a time
> Is there a significant difference in speed, style, or any pythonesque
> reasoning between Alan's solution and
> print message[::-1]
Yes, the for loop doing one character at a time will be much
slower than using a slice. The slice is more pythonic but less general.
A reverse loop is something
On 9/23/2009 7:22 AM Ali Sina said...
#Message backward printer
message=input('Enter your message: ')
for i in range(len(message),0,-1):
print(message)
This is the code which I have written. All it does is count the number of
letters starting from backwards. The proper code should so some
Is there a significant difference in speed, style, or any pythonesque
reasoning between Alan's solution and
print message[::-1]
Thanks for any information,
Robert
On Wed, 2009-09-23 at 18:51 +0100, Alan Gauld wrote:
> "Ali Sina" wrote
>
> #Message backward printer
> message=input('Enter you
"Ali Sina" wrote
#Message backward printer
message=input('Enter your message: ')
for i in range(len(message),0,-1):
print(message)
This is the code which I have written.
All it does is count the number of letters starting from backwards.
Correct, plus it prints the original message eac
> http://docs.python.org/tutorial/introduction.html#strings
>
The below page is a better introduction to sequences:
http://effbot.org/zone/python-list.htm
It uses lists, but the lessons on slicing also apply to strings (which
are a type of sequence).
HTH!
Serdar
Try reading up on sequences and slicing. They offer a very elegant solution
to your (homework?) problem.
http://docs.python.org/tutorial/introduction.html#strings
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http
#Message backward printer
message=input('Enter your message: ')
for i in range(len(message),0,-1):
print(message)
This is the code which I have written. All it does is count the number of
letters starting from backwards. The proper code should so something like this:
Enter your message: Hi
13 matches
Mail list logo