On 03/31/2015 04:23 PM, boB Stepp wrote:
The following behavior has me stumped:
Python 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit
(Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
L = ['#ROI:roi_0', '#TXT:text_0', '#1:one^two^three']
for i, item in enumerate(L):
subitems = item.split(':')
if subitems[0] == '#ROI':
print subitems[1]
if subitems[0] == '#TXT':
print subitems[1]
if subitems[0] == '#1' or '#2':
I think what you meant here was:
if subitems[0] == "#1" or subitems[0] == "#2":
print subitems[1]
Study the first expression and see if you can figure out what the
difference is. If it's not clear, then make a simpler program just to
test a compound if, and we'll all talk about it.
roi_0ail
roi_0
text_0
text_0
one^two^three
My desired output was:
roi_0
text_0
one^two^three
Oh, wonderful founts of wisdom, where is my understanding lacking?
BTW, I copied and pasted the above into my Gmail window, but it
removed the indentation that was present in the interpreter. I added
spaces manually to get it appear as it did in the interpreter. Anyone
know why Gmail does that to my copy and paste?
Buggy, I guess. Why not use a program like Thunderbird, which is free
and available on most PC operating systems?
(Unfortunately, it's not on Android)
--
DaveA
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor