[Tutor] yet another misunderstanding on my part
Clayton Kirkwood
crk at godblessthe.us
Wed Oct 22 06:54:49 CEST 2014
__author__ = 'SYSTEM'
import string
#Pricing Dividends
raw_table = ('''
a: Ask y: Dividend Yield
b: Bid d: Dividend per Share
b2: Ask (Realtime) r1: Dividend Pay Date
b3: Bid (Realtime) q: Ex-Dividend Date
p: Previous Close
o: Open
import re, string
col_position, code, description = 0, [], []
key_name = raw_table.replace('\t','\n')
for each_line in key_name.splitlines():
if ':' in each_line:
code[col_position], description.append() = each_line.split(':')
#neither works; first one is out of range error, 2nd, can't assign to
#function. I've used square brackets around various sections, and it doesn't
like it
c, d = each_line.split(':')
#this works
code[col_position] = each_line.split(':') #why doesn't this.
It looks like what is in the tutorial 5.1. I get out of range error
code.append(c)
#part of the first 'this works' line
code[col_position] = 5
#this works, yet I am using the same col_position element
description.append(d)
print( col_position, code[col_position], description[col_position])
col_position += 1
I've seen an example of description.strip() work from a for in loop
assignment with out the can't assign to function.
I'd like to see something like:
code[col_position].strip(), description[col_position].stripe() =
each_line.split(':')
but for some reason, the [col_position] doesn't work, and I can't strip().
What am I not seeing? I *do* spend hours trying different options, and study
various documentation which confuse me and don't seem consistent.
Thanks,
Clayton
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20141021/5c5e7827/attachment.html>
More information about the Tutor
mailing list