Hey, I'm on the rookie side, to Python, and Pygame and new to this community, and I'm confused if this could be possible; I want to change the data type of a list, in Python, from strings to integer (they have to be integer, because I need to sort them numerically afterwards).

This is what I have:

fil2 = open('scrs.dat', 'r')
reads = fil2.read()
splits = reads.split('=')
print(splits)

>>>
That is what it outputs, but of course the data type is string; the function of this code is to read data which is wrote previously to the file so to store high scores for my game. And I'd want to sort them in numerical order, so is there any method of changing each value to an integer in the list?

There is plenty of ways, most recomendable is to use list comprehension:

splits = [int(n) for n in splits]

If you only want to sort them numerically, simplest is to use int as key for sorted-function.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.