473,320 Members | 1,854 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

#comments

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.

Jul 18 '05 #1
10 1661
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.

Jul 18 '05 #2
On 13 Sep 2004 22:27:32 Ken Parkes <cb*****@NOSPAMrosecott.ukfsn.org> wrote:
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 ....
Jul 18 '05 #3

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
Jul 18 '05 #4
Your subject is about comments, but your problem is with
your print statements. See below.

Ken Parkes writes:
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."

--
Paul McNett
Independent Software Consultant
http://www.paulmcnett.com
Jul 18 '05 #5
On Mon, 13 Sep 2004 21:30:36 +0000, F. Petitjean wrote:
On 13 Sep 2004 22:27:32 Ken Parkes <cb*****@NOSPAMrosecott.ukfsn.org>
wrote:
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.
Jul 18 '05 #6
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.
"Ken Parkes" <cb*****@NOSPAMrosecott.ukfsn.org> wrote in message
news:pa****************************@NOSPAMrosecott .ukfsn.org...

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

Jul 18 '05 #7


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

Ken.
Jul 18 '05 #8
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
"Ken Parkes" <cb*****@NOSPAMrosecott.ukfsn.org> wrote in message
news:pa****************************@NOSPAMrosecott .ukfsn.org...
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.

Jul 18 '05 #9
Ken Parkes <cb*****@NOSPAMrosecott.ukfsn.org> wrote in message news:<pa****************************@NOSPAMrosecot t.ukfsn.org>...
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 ")
Jul 18 '05 #10
On Mon, 13 Sep 2004 21:51:17 -0700, Dan Bishop wrote:


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.

Jul 18 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Sims | last post by:
Hi, I proud myself in having good comments, (/**/, // etc...), all over my scripts as well as a very descriptive section at the beginning of the script. No correct me if i am wrong but php must...
17
by: lkrubner | last post by:
I've got a PHP application that's 2 megs in size. Of that, my guess is 200k-400k is comments. Do they impose a performance hit? I've been postponing any kind of optimization, but at some point I'll...
4
by: Uwe Ziegenhagen | last post by:
Hello, my fellows and me implement a c++ tool that is able to divide blank/tab separated files into <number>, <text>, <c-singlelinecomment> and <multilinecomment>. So far it's not working bad,...
28
by: Benjamin Niemann | last post by:
Hello, I've been just investigating IE conditional comments - hiding things from non-IE/Win browsers is easy, but I wanted to know, if it's possible to hide code from IE/Win browsers. I found...
4
by: lorinh | last post by:
Hi Folks, I'm trying to strip C/C++ style comments (/* ... */ or // ) from source code using Python regexps. If I don't have to worry about comments embedded in strings, it seems pretty...
40
by: Edward Elliott | last post by:
At the risk of flogging a dead horse, I'm wondering why Python doesn't have any multiline comments. One can abuse triple-quotes for that purpose, but that's obviously not what it's for and doesn't...
7
by: Bob Stearns | last post by:
Several weeks ago I asked what comments I could pass to DB2 in a SELECT statement. I don't remember whether I said via PHP/ODBC. I was assured that both /* */ style comment blocks and -- comment...
98
by: tjb | last post by:
I often see code like this: /// <summary> /// Removes a node. /// </summary> /// <param name="node">The node to remove.</param> public void RemoveNode(Node node) { <...> }
40
by: jacob navia | last post by:
Recently we had poor Mr "teapot" that was horrified at the heresy of lcc-win of accepting // comments. C is a nice language, and you can do anything with it, inclusive a program that transforms...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.