• Ald

    You are a top guy! Thanks for the tips and help.

    posted in Pythonista read more
  • Ald

    Hi folks

    I am new to phythonista, iPad and Python. I need the following code to open up a text file in the script folder of pythonista :

    scores = {}
    result_f = open("results.txt")
    for line in result_f:
    (name, score) = line.split()
    scores[score] = name
    result_f.close()
    print("the top scores were:")
    for each_score in scores.keys():
    print('surfer' + scores[each_score]+'scored'+each_score)

    The contents of results.txt is:
    Johnny 8.65
    Juan 9.12
    Joseph 8.45
    Stacey 7.81
    Aideen 8.05
    Zack 7.21
    Aaron 8.31

    posted in Pythonista read more
  • Ald

    Ok it works now, it turns out my results.txt file had some blank lines at the end that obviously caused the trouble

    posted in Pythonista read more
  • Ald

    Wow thanks for that. I will learn a lot from the second method. I am going through a book called head first programming and just doing all the tutorials.

    Ok it also seems as if the code I insert must be inserted within [] as pointed out to me kindly above.

    posted in Pythonista read more
  • Ald

    Don't think that worked either

    posted in Pythonista read more
  • Ald

    Let's try

    
    [scores = {}
    result_f = open("results.txt")
    for line in result_f:
        (name, score) = line.split()
        scores[score] = name
    result_f.close()
    print("the top scores were:")
    for each_score in scores.keys():
        print('surfer' + scores[each_score]+'scored'+each_score)]
    
    

    `python

    scores = {}
    result_f = open("results.txt")
    for line in result_f:
    (name, score) = line.split()
    scores[score] = name
    result_f.close()
    print("the top scores were:")
    for each_score in scores.keys():
    print('surfer' + scores[each_score]+'scored'+each_score)

    `

    posted in Pythonista read more
  • Ald

    `python

    scores = {}
    result_f = open("results.txt")
    for line in result_f:
    (name, score) = line.split()
    scores[score] = name
    result_f.close()
    print("the top scores were:")
    for each_score in scores.keys():
    print('surfer' + scores[each_score]+'scored'+each_score)
    `

    posted in Pythonista read more
  • Ald

    Thanks

    posted in Pythonista read more
  • Ald

    ' ' 'python
    scores = {}
    result_f = open("results.txt")
    for line in result_f:
    (name, score) = line.split()
    scores[score] = name
    result_f.close()
    print("the top scores were:")
    for each_score in scores.keys():
    print('surfer' + scores[each_score]+'scored'+each_score)
    ' ' '

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!