"Clayton Kirkwood" <[email protected]> Wrote in message:
> Thanks all for the insight. I'm not sure I fully understand all of the code
> snippets, but in time...
>
> This is finally what I came up with:
>
> 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
> Date
> ''')
>
>
> import re, string
> dict={}
> key_name = raw_table.replace('\t','\n')
> for each_line in key_name.splitlines():
> if ':' in each_line: #this design had to
> do with a few different lines
> for key, value in [each_line.split(':')]: #see the last line
> in the data. I still don't fully
> dict[key.strip()] = value.strip() #understand the second for
> and the square brackets.
>
> #I presume that they force the source to look and feel like a tuple or list,
> but not sure. I think they force two strings into a two items of a tuple???
> Please let me know if I munged bad code together:<))
I dont think you want the for loop at all. It just undoes the
mistake of the extra brackets. Try replacing the for loop with
:
key, value in each_line.split(':')
And dedent the following line
--
DaveA
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor