Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

I always got this error!! ValueError: invalid literal for int() with base 10: ''

So this is my code. At first it worked but then started to malfunction. Can you help me to solve this?

Code:

score=[]

def ler_score():
    global score
    f=open("score.ppp","r")
    l=1
    for linha in f:
        if l==1:
            score=score+[list(range(2))]
        i=len(score)-1
        linha=linha[:len(linha)-1]
        #l=1 -> nome l=2 -> score
        if l==1:
            score[i][1]=linha
        if l==2:
            linha=int(linha)
            score[i][0]=linha
        l+=1
        if l>2:
            l=1
    f.close()
    score.sort()
    score.reverse()


def grava_score(nome,pontos):
    global score

    score.sort()
    score.reverse()
    if pontos>score[len(score)-1][0]:
        score[len(score)-1][0]=pontos
        score[len(score)-1][1]=nome
    score.sort()
    score.reverse()

    f=open("score.ppp","w")
    for i in range(0,10):
        f.write(score[i][1])
        f.write("\n")
        f.write(str(score[i][0]))
        f.write("\n")
    f.close()


print(score)
ler_score()
print(score)
n=input("Nome:")
p=int(input("pontos:"))

grava_score(n,p)

print(score)

Error:

Traceback (most recent call last):
  File "score.py", line 47, in <module>
    ler_score()
  File "score.py", line 16, in ler_score
    linha=int(linha)
ValueError: invalid literal for int() with base 10: ''

I want to save scores for a game I'm making for my class, the teacher tough me how to do it and I understand it but know I can't move on and I can't solve this (Sorry to tell you the story of my life but i need to right stuff for StackOverflow to let me post this)

Comments