[LUNA] Python question

Paul F. Pearson pfpearson at mchsi.com
Tue Oct 18 08:44:15 CDT 2016


Ive not done Python, but it appears that you're trying to declare golf to be a list.

According to [1], lists are declared with square brackets ('[]'). So, to get correct syntax, I think it would be:

--- begin code 

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()

--- end code



[1] http://stackoverflow.com/questions/1514553/how-to-declare-an-array-in-python#1514557

----- Original Message -----
> 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
> 


More information about the LUNA mailing list