[Tutor] creating dictionary from a list
Saad Bin Javed
sbjaved at gmail.com
Sat Apr 13 21:30:51 CEST 2013
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
More information about the Tutor
mailing list