rmd: (sweeney)
[personal profile] rmd
ETA: solved!

Very basic python question for folks what know python.

So, I'm messing about with python a bit (rev 2.7.3), and I'm doing some very basic just-above-hello-world stuff. I want to take two lines of input and merge them, but if the second line starts with a + (like some text clients do when inserting a line break), I want to delete the +. But this:
import sys
line1 = sys.stdin.readline()[:-1]
line2 = sys.stdin.readline()[:-1]
if line2[0] == '\+'
 line1 = line1 + line2[1:]
print line1


fails with this error message:
  File "foo.py", line 4
    if line2[0] == '\+'
                      ^
SyntaxError: invalid syntax


I tried using " quotes and with and without the \ escape character. What's the right syntax, here? (google was unhelpful, or at least I had too much trouble distilling the results down to things that were relevent.)
also, man, python is weird!

Date: 2013-07-15 08:13 pm (UTC)
From: [identity profile] miss-chance.livejournal.com
Do pythons have colons?

(the reptile, not the language)

Date: 2013-07-15 08:44 pm (UTC)
From: [identity profile] rmd.livejournal.com
See, *that*, google can help me with. yes! (http://en.wikivet.net/Snake_Digestive_System)

Date: 2013-07-16 03:50 am (UTC)
muffyjo: (conscience)
From: [personal profile] muffyjo
I am amused. I wish I were also helpful, but it's not in my toolset. So I can only sit here on the sidelines, reading, and being so very, very amused.

Profile

rmd: (Default)
rmd

June 2025

S M T W T F S
1234567
89 1011121314
15161718192021
22232425262728
2930     

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jan. 19th, 2026 06:57 am
Powered by Dreamwidth Studios