470,594 Members | 1,499 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,594 developers. It's quick & easy.

Newb ?

Hello all,

Have a problem here with a challenge from a book I am reading.
Any help is much appreciated.

I am trying to run a program that asks the user for a statement and then
prints it out backwards.
this is what I have.
It does not print anything out. I assume that I have something out of whack
with my high and low statements.

Thanks for you help.
print "\n\nWelcome to the Backwards Message Display."
print
message = raw_input("\nPlease Enter a Message.")

high = len(message)
low = -len(message)
print
print message[high:low]
print
print raw_input("Please Press Enter to Exit")
Nov 22 '05 #1
14 1163
Chad Everett wrote:
Hello all,

Have a problem here with a challenge from a book I am reading.
Any help is much appreciated.

I am trying to run a program that asks the user for a statement and then
prints it out backwards.
this is what I have.
It does not print anything out. I assume that I have something out of whack
with my high and low statements.

Thanks for you help.
print "\n\nWelcome to the Backwards Message Display."
print
message = raw_input("\nPlease Enter a Message.")

high = len(message)
low = -len(message)
print
print message[high:low]
print
print raw_input("Please Press Enter to Exit")


Are you sure that this is not a class assignment? You can search the
messages here for the answer.
Nov 22 '05 #2
Chad Everett wrote:
Hello all,

Have a problem here with a challenge from a book I am reading.
Any help is much appreciated.

I am trying to run a program that asks the user for a statement and then
prints it out backwards.
this is what I have.
It does not print anything out. I assume that I have something out of whack
with my high and low statements.

Thanks for you help.
print "\n\nWelcome to the Backwards Message Display."
print
message = raw_input("\nPlease Enter a Message.")

high = len(message)
low = -len(message)
print
print message[high:low]
print
print raw_input("Please Press Enter to Exit")


Are you sure that this is not a class assignment? You can search the
messages here for the answer.
Nov 22 '05 #3

"Paul Watson" <pw*****@redlinepy.com> wrote in message
news:3t************@individual.net...
Chad Everett wrote:
Hello all,

Have a problem here with a challenge from a book I am reading.
Any help is much appreciated.

I am trying to run a program that asks the user for a statement and then
prints it out backwards.
this is what I have.
It does not print anything out. I assume that I have something out of
whack with my high and low statements.

Thanks for you help.
print "\n\nWelcome to the Backwards Message Display."
print
message = raw_input("\nPlease Enter a Message.")

high = len(message)
low = -len(message)
print
print message[high:low]
print
print raw_input("Please Press Enter to Exit")


Are you sure that this is not a class assignment? You can search the
messages here for the answer.


No, I have been out of school way too long. I am 34 trying to learn a new
trade. I searched the group for the term backwards but I did not get any
results.
Nov 22 '05 #4

"Paul Watson" <pw*****@redlinepy.com> wrote in message
news:3t************@individual.net...
Chad Everett wrote:
Hello all,

Have a problem here with a challenge from a book I am reading.
Any help is much appreciated.

I am trying to run a program that asks the user for a statement and then
prints it out backwards.
this is what I have.
It does not print anything out. I assume that I have something out of
whack with my high and low statements.

Thanks for you help.
print "\n\nWelcome to the Backwards Message Display."
print
message = raw_input("\nPlease Enter a Message.")

high = len(message)
low = -len(message)
print
print message[high:low]
print
print raw_input("Please Press Enter to Exit")


Are you sure that this is not a class assignment? You can search the
messages here for the answer.


No, I have been out of school way too long. I am 34 trying to learn a new
trade. I searched the group for the term backwards but I did not get any
results.
Nov 22 '05 #5
Chad Everett <ev*******@hotmail.com> wrote:
I searched the group for the term backwards but I did not get any
results.


You might have better results searching for 'reverse'.

--
\ "For certain people, after fifty, litigation takes the place of |
`\ sex." -- Gore Vidal |
_o__) |
Ben Finney
Nov 22 '05 #6
Chad Everett <ev*******@hotmail.com> wrote:
I searched the group for the term backwards but I did not get any
results.


You might have better results searching for 'reverse'.

--
\ "For certain people, after fifty, litigation takes the place of |
`\ sex." -- Gore Vidal |
_o__) |
Ben Finney
Nov 22 '05 #7
Chad Everett wrote:
"Paul Watson" <pw*****@redlinepy.com> wrote in message
news:3t************@individual.net...
Chad Everett wrote:
high = len(message)
low = -len(message)
print
print message[high:low]
print
print raw_input("Please Press Enter to Exit")


Are you sure that this is not a class assignment? You can search the
messages here for the answer.

No, I have been out of school way too long. I am 34 trying to learn a new
trade. I searched the group for the term backwards but I did not get any
results.


The problem is that negative numbers mean "count from the rightmost end
of the string or list." Also, you are going high to low without any
indication that you mean to go backwards.
message = raw_input("Enter a Message:")
print message[: : -1]


-Scott David Daniels
sc***********@acm.org
Nov 22 '05 #8
Chad Everett wrote:
"Paul Watson" <pw*****@redlinepy.com> wrote in message
news:3t************@individual.net...
Chad Everett wrote:
high = len(message)
low = -len(message)
print
print message[high:low]
print
print raw_input("Please Press Enter to Exit")


Are you sure that this is not a class assignment? You can search the
messages here for the answer.

No, I have been out of school way too long. I am 34 trying to learn a new
trade. I searched the group for the term backwards but I did not get any
results.


The problem is that negative numbers mean "count from the rightmost end
of the string or list." Also, you are going high to low without any
indication that you mean to go backwards.
message = raw_input("Enter a Message:")
print message[: : -1]


-Scott David Daniels
sc***********@acm.org
Nov 22 '05 #9
"Chad Everett" <ev*******@hotmail.com> writes:
print "\n\nWelcome to the Backwards Message Display."
print
message = raw_input("\nPlease Enter a Message.")


Since you said it wasn't a school assignment, and I'm a trusting soul,
the next line could be:

print message[::-1]

<mike

--
Mike Meyer <mw*@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Nov 22 '05 #10
"Chad Everett" <ev*******@hotmail.com> writes:
print "\n\nWelcome to the Backwards Message Display."
print
message = raw_input("\nPlease Enter a Message.")


Since you said it wasn't a school assignment, and I'm a trusting soul,
the next line could be:

print message[::-1]

<mike

--
Mike Meyer <mw*@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Nov 22 '05 #11
Hey guys,

Thanks for the hint.
I found that info last night but I could never get it to print more than
just the last letter.
or it would only print partially.
I was using just a single colon, the double colon did it.

Thanks

"Chad Everett" <ev*******@hotmail.com> wrote in message
news:f1*******************@bignews7.bellsouth.net. ..
Hello all,

Have a problem here with a challenge from a book I am reading.
Any help is much appreciated.

I am trying to run a program that asks the user for a statement and then
prints it out backwards.
this is what I have.
It does not print anything out. I assume that I have something out of
whack with my high and low statements.

Thanks for you help.
print "\n\nWelcome to the Backwards Message Display."
print
message = raw_input("\nPlease Enter a Message.")

high = len(message)
low = -len(message)
print
print message[high:low]
print
print raw_input("Please Press Enter to Exit")

Nov 22 '05 #12
Hey guys,

Thanks for the hint.
I found that info last night but I could never get it to print more than
just the last letter.
or it would only print partially.
I was using just a single colon, the double colon did it.

Thanks

"Chad Everett" <ev*******@hotmail.com> wrote in message
news:f1*******************@bignews7.bellsouth.net. ..
Hello all,

Have a problem here with a challenge from a book I am reading.
Any help is much appreciated.

I am trying to run a program that asks the user for a statement and then
prints it out backwards.
this is what I have.
It does not print anything out. I assume that I have something out of
whack with my high and low statements.

Thanks for you help.
print "\n\nWelcome to the Backwards Message Display."
print
message = raw_input("\nPlease Enter a Message.")

high = len(message)
low = -len(message)
print
print message[high:low]
print
print raw_input("Please Press Enter to Exit")

Nov 22 '05 #13
Chad Everett wrote:
Hey guys,

Thanks for the hint.
I found that info last night but I could never get it to print more than
just the last letter.
or it would only print partially.
I was using just a single colon, the double colon did it.


If you were using a single colon, then it would print everything except
the last character. Use the Python interactive mode for experimentation.

$ python
Python 2.4.1 (#1, Jul 19 2005, 14:16:43)
[GCC 4.0.0 20050519 (Red Hat 4.0.0-8)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
s = 'abc'
s 'abc' s[:-1] 'ab' s[-1]

'c'
Nov 22 '05 #14
Chad Everett wrote:
Hey guys,

Thanks for the hint.
I found that info last night but I could never get it to print more than
just the last letter.
or it would only print partially.
I was using just a single colon, the double colon did it.


If you were using a single colon, then it would print everything except
the last character. Use the Python interactive mode for experimentation.

$ python
Python 2.4.1 (#1, Jul 19 2005, 14:16:43)
[GCC 4.0.0 20050519 (Red Hat 4.0.0-8)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
s = 'abc'
s 'abc' s[:-1] 'ab' s[-1]

'c'
Nov 22 '05 #15

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by claudel | last post: by
reply views Thread by David E. | last post: by
5 posts views Thread by Alexandre | last post: by
3 posts views Thread by Walter | last post: by
3 posts views Thread by claudel | last post: by
1 post views Thread by notbob | last post: by
4 posts views Thread by Donald Newcomb | last post: by
6 posts views Thread by Sean Berry | last post: by
11 posts views Thread by The_Kingpin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.