[Tutor] creating dictionary from a list

Mark Lawrence breamoreboy at yahoo.co.uk
Sat Apr 13 21:56:55 CEST 2013


On 13/04/2013 20:30, Saad Bin Javed wrote:
> On 04/14/2013 12:08 AM, Mark Lawrence wrote:
>> On 13/04/2013 19:45, Saad Javed wrote:
>>>
>>>              for item in lst:
>>>                   if
>>>
>>>
>>> item.startswith(('Mon','Tue','____Wed','Thu','Fri','Sat','Sun'__))__:
>>>                       myDict[item] = []
>>>                       saveItem = item
>>>                   else:
>>>                       myDict[saveItem].append(item.____strip())
>>>
>>> Returns:
>>>   File "gcalcli_agenda_test.py", line 38
>>>      if
>>> item.startswith(('Mon','Tue','__Wed','Thu','Fri','Sat','Sun'))__:
>>>                                                                        ^
>>> SyntaxError: invalid syntax
>>>
>>
>> Please compare your original line with the line above and note the
>> differences.  That'll account for the syntax error, which appears to
>> have been introduced by your email client.
>>
> This is what I'm using:
>
> for item in lst:
>      if
> item.startswith(('Mon','Tue','____Wed','Thu','Fri','Sat','Sun'__))__:
>          dict[item] = []
>          saveItem = item
>      else:
>          dict[saveItem].append(item.____strip())
>
> gives:
>   File "gcalcli_agenda_test.py", line 39
>      if
> item.startswith(('Mon','Tue','____Wed','Thu','Fri','Sat','Sun'__))__:
>                                                                        ^
> SyntaxError: invalid syntax
>

Please compare your original line with the line above and note the
differences.  That'll account for the syntax error, which appears to
have been introduced by your email client.

-- 
If you're using GoogleCrap™ please read this 
http://wiki.python.org/moin/GoogleGroupsPython.

Mark Lawrence



More information about the Tutor mailing list