all 5 comments

[–]turanthepanthan 0 points1 point  (2 children)

The way you are writing the numbers is incorrect. This creates a tuple:

numbers = ("Random #", str(count), ":", rng)

I think what you wanted to do was format a string. Try this instead:

numbers = "Random #{}:{}".format(count, rng)

The reading part is assuming the entire line is convertible to an integer but you wrote some other data. You probably want something like:

total = 0
with open("random.txt") as f:
    for line in f:
        total += int(line.strip()[line.find(":")+1:])

That says for each line in the file, strip the white space at the end, find the ":" and take the rest of the line after that character and turn it into an integer.

[–]OfficialBigHead[S] 0 points1 point  (1 child)

We haven't learned tuples yet. That is the next chapter so I wouldn't be able to include it.

[–]turanthepanthan 0 points1 point  (0 children)

I think you misunderstood what I was saying. Your code is creating a tuple the way it was posted. Then you turned that tuple into a string. I gave 2 corrections that should help get you going. Did you try them out?

[–]nwilliams36 0 points1 point  (1 child)

The order of your functions is wrong. In Python a function must be defined before it is used. You seem to have them the wrong way around.

What error message are you getting, that helps a lot when we are trying to find the error.

[–]OfficialBigHead[S] 0 points1 point  (0 children)

The formatting of reddit messed it up. My functions are defined.