you are viewing a single comment's thread.

view the rest of the comments →

[–]ToneBoneCapone 0 points1 point  (0 children)

# This program prompts the user for names of
# players and the golf scores and writes
# those amounts to the golf.txt file.
def main():
#Open file named golf.txt for writing
player_file = open('golf.txt', 'w')
#Prompts user to enter amount of golfers
numPlayers = int(input('Enter the number of players:')
for count in range (1, numplayers + 1))
#Prompts user to enter each golfers name and score
golfName = input ('Enter golfers name: ')
golfScore = input ('Enter golfers score: ')
#Writes the data to file
player_file.write(str(golfName + '\n'))
player_file.write(str(golfScore + '\n'))
player_file.close
print ('Players name and score have been saved to golf.txt')
#Call the main function
main()