[LUNA] Python question

Joshua Krasnow jmk1 at fastmail.fm
Mon Oct 17 22:02:01 CDT 2016


1) try running it iPython

2) why is the golf dict global? Why not just golf = {}? Also there's a
typo when writing the dict: s/gofl/golf

On 10/17/2016 09:16 PM, Michael W. Hall wrote:
> Yep. Not really a good example I can find.
>
> On Mon, 2016-10-17 at 21:01 -0500, Chris Brightwell wrote:
>> Did you try googling the error?
>>
>>> On Oct 17, 2016, at 8:47 PM, Michael W. Hall <hallmw at att.net>
>>> wrote:
>>>
>>> Trying to help a friend.  I am getting an error on the following
>>> program.
>>>
>>> global golf{}
>>> name = ""
>>> while name != 1:
>>>    name = input("Golfer's name? ")
>>>    score = input("Golfer's score? ")
>>>    golf[name]=score
>>>
>>> file = open("","w")
>>>
>>> for key in golf:
>>>    file.write(key, gofl[key])
>>>
>>> file.close()
>>>
>>> golf is supposed to be a dictionary, but I am getting an error on
>>> the
>>> first line.
>>>
>>> Any ideas?
>>> _______________________________________________
>>> LUNA mailing list
>>> LUNA at lunagroup.us
>>> http://lunagroup.us/mailman/listinfo/luna
>> -------------- next part --------------
>> An HTML attachment was scrubbed...
>> URL: <http://lunagroup.us/pipermail/luna/attachments/20161017/e793e5c
>> 2/attachment.html>
>> _______________________________________________
>> LUNA mailing list
>> LUNA at lunagroup.us
>> http://lunagroup.us/mailman/listinfo/luna
> _______________________________________________
> LUNA mailing list
> LUNA at lunagroup.us
> http://lunagroup.us/mailman/listinfo/luna




More information about the LUNA mailing list