#comments

K

Ken Parkes

Hi,
New to this game. Have tried the following.

data=raw_input("Type something ") # spaces after "something"
myInput=data
print "You typed " myInput # and again
print "The fourth character is "myInput[3] # and again

When I run it in the shell I get error warnings for the second comment
( actually pointing to the t of myInput ) If I remove the comment I get
one for the third comment. What is wrong please?

Ken.
 
F

F. Petitjean

Hi,
New to this game. Have tried the following.

data=raw_input("Type something ") # spaces after "something"
myInput=data
print "You typed " myInput # and again
print "You typed ", myInput # and again # note the comma
print "The fourth character is "myInput[3] # and again
print "The fourth character is ", myInput[3] # and again # same
When I run it in the shell I get error warnings for the second comment
( actually pointing to the t of myInput ) If I remove the comment I get
one for the third comment. What is wrong please?
The print statement is :
print item1, item2 ....
 
K

Ken Parkes

On Mon, 13 Sep 2004 22:27:32 +0100, Ken Parkes wrote:


Oops, sorry that should have been


data=raw_input("Type something ") # spaces after "something"
myInput=data
print "You typed " myInput # and again
print "The fourth character is " myInput[3] # and again

Ken.
 
P

Paul McNett

Your subject is about comments, but your problem is with
your print statements. See below.

Ken said:
data=raw_input("Type something ") # spaces after
"something" myInput=data
print "You typed " myInput # and again
print "The fourth character is " myInput[3] # and
again

Try this:

data=raw_input("Type something ") # spaces after "something"
myInput=data
print "You typed %s" % myInput # and again
try:
print "The fourth character is %s" % myInput[3] # and again
except IndexError:
print "There is no fourth character."
 
K

Ken Parkes

Oh lord, start again:-

data=raw_input("Type something ") # spacer after "something"
myInput=data
print "You typed " myInput # and again
print "The fourth character is "myInput[3] # and again
 
K

Ken Parkes

Hi,
New to this game. Have tried the following.

data=raw_input("Type something ") # spaces after "something"
myInput=data
print "You typed " myInput # and again
print "You typed ", myInput # and again # note the comma
print "The fourth character is "myInput[3] # and again
print "The fourth character is ", myInput[3] # and again # same
When I run it in the shell I get error warnings for the second comment (
actually pointing to the t of myInput ) If I remove the comment I get
one for the third comment. What is wrong please?
The print statement is :
print item1, item2 ....

Ah, I see, thank you for that. A follow up please. Do you see the last
line beginning with < print "The fourth..... > ? Pan is chopping the
lines up on my monitor.

Thanks Ken.
 
L

Larry Bates

Not a comment problem. You need commas after
literals in the print statements

print "You typed", myInput # and again

or

print "You typed %s" % myInput # and again

Larry Bates
Syscon, Inc.
 
K

Ken Parkes

Thanks to all for the wisdom, one small step etc. And Pan sorted, not
bad for an evenings work.

Ken.
 
D

Dan Perl

You're missing a comma between the arguments in "print". Here is how it
should be:
data=raw_input("Type something ") # spaces after "something"
myInput=data
print "You typed ", myInput # and again
print "The fourth character is ", myInput[3] # and again
 
D

Dan Bishop

Ken Parkes said:
Hi,
New to this game. Have tried the following.

data=raw_input("Type something ") # spaces after "something"
myInput=data

This isn't related to your question, but why are you using two
assignment statements when one will do?

myInput = raw_input("Type something ")
 
K

Ken Parkes

This isn't related to your question, but why are you using two assignment
statements when one will do?

myInput = raw_input("Type something ")


All to do with my background-learning by trial and error. I was simply
trying various ways of assignment. When one gets long in the tooth read
stuff tends to evaporate. Got to Handling Exceptions in van Rossum's
tutorial today and saw the first instance of
print itemA , itemB
Now I shall not forget and have a mental link with
while something : somethingElse
Two pains for the price of one.

And thanks to Dan Perl; there's a name to conjure with:)

Ken.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top